开发者

Jekyll/Liquid - how to add large blocks of text to YAML front matter?

开发者 https://www.devze.com 2023-03-20 21:49 出处:网络
I\'m trying to implement a service catalog in Jekyll, in which each of 20 or 30 pages will contain a 7x2 table.The left column will hold labels, e.g. Overview, Available To, etc, while the right colum

I'm trying to implement a service catalog in Jekyll, in which each of 20 or 30 pages will contain a 7x2 table. The left column will hold labels, e.g. Overview, Available To, etc, while the right column will hold between one line and several paragraphs of text. I was hoping to characterize the right column with Liquid variables, e.g. {overview}, {availableTo}

I've noticed that the YAML seems to be very picky about line breaks, and accordingly I've had to input these paragraphs and their markup on one line which can go on for several screen-widths. This is a problem because it's annoying, and also because I'd like these front-matters to be editable by tech开发者_如何学运维nical but non-webdev users. Is there a way to have the front matter tolerate breaks?

Alternatively, is there a way that I could populate this table with the {content} section, without having to recode the table into it each time?


Yaml syntax for multi-line strings is this one:

body: |
  This is a multi-line string.
  "special" metacharacters may
  appear here. The extent of this string is
  indicated by indentation. 

Notice that the first line must be an space followed by the | character and a new line. Then you must indent the text one level more than its parent.

Consequently, you can create one item this way:

item1:
  overview: |
    overview text
    more overview text
  available_to: 2012-01-01
  foo: |
    foo text
    more foo text

It seems to me that you also want to arrange your items in order. You can employ a yaml list for that:

catalog:
  - id: item 1
    overview: |
      overview text
      more overview text
    available_to: 2012-01-01
    foo: |
      foo text
      more foo text
    ...
  - id: item2
    overview: <similar to above>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号