yaml 学习笔记

博客分类: note 阅读次数: 🤔

yaml 学习笔记

yaml

原文地址:https://zhangjinbo619.github.io/note/2018/05/30/yaml.html

目的

因个人博客通过jekyll搭建,后发现_config.yml里面的语法比较神奇,可读性极高。所以查了相关资料,想具体了解下该标记语言的特性和应用场景。

什么是yaml?

YAML =”YAML Ain’t Markup Language”

为什么要用yaml?

什么时候用yaml?

商城的发票日志demo

--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.

错误日志demo

  ---
  Time: 2001-11-23 15:01:42 -5
  User: ed
  Warning:
    This is an error message
    for the log file
  ---
  Time: 2001-11-23 15:02:31 -5
  User: ed
  Warning:
    A slightly different error
    message.
  ---
  Date: 2001-11-23 15:03:17 -5
  User: ed
  Fatal:
    Unknown variable "bar"
  Stack:
    - file: TopClass.py
      line: 23
      code: |
        x = MoreObject("345\n")
    - file: MoreClass.py
      line: 58
      code: |-
        foo = bar

配置项demo

--- #这个例子就是该文章yaml配置,是不是一目了然、通俗易懂 ^_^
layout: blog
tech: true
title: "yaml 学习笔记"
background-image: "http://zhangjinbo619-github.oss-cn-hangzhou.aliyuncs.com/zhangjinbo619.github.io/yaml-logo.png"
date: "2018-05-30"
category: note #book,game,note,chat,code,image,web,link,design,lock
tags:
- yaml
---

参考