Jekyll/Liquid - 如何将大块文本添加到 YAML 前面的内容?
我正在尝试在 Jekyll 中实现一个服务目录,其中每 20 或 30 个页面将包含一个 7x2 表。左列将包含标签,例如“概述”、“可用”等,而右列将包含一行和多个文本段落之间的内容。我希望用 Liquid 变量来表征右列,例如 {overview}、{availableTo}
我注意到 YAML 似乎对换行符非常挑剔,因此我必须在上输入这些段落及其标记一行可以持续几个屏幕宽度。这是一个问题,因为它很烦人,而且还因为我希望这些前端问题可以由技术用户但非 Webdev 用户编辑。有没有办法让前面的内容能够容忍中断?
或者,有没有一种方法可以使用 {content} 部分填充此表,而不必每次都将表重新编码到其中?
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 technical 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多行字符串的 Yaml 语法是这个:
注意第一行必须是一个空格,后跟
|
字符和新行。然后,您必须将文本比其父级缩进一级。因此,您可以通过这种方式创建一个项目:
在我看来,您也想按顺序排列您的项目。您可以为此使用 yaml 列表:
Yaml syntax for multi-line strings is this one:
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:
It seems to me that you also want to arrange your items in order. You can employ a yaml list for that: