Liquid 逻辑语言

01 Dec 2011

Textile & Markdown

为避免直接编写 html 代码,编写文章时,内容需要加入标记信息,即 Textile,Markdown

  • 标记语言有很多种,如 Textile,Markdown(我选用的是 Textile)
  • 这些标记语言会被标记引擎转换,输出成相应的目标格式(大部分情况是输出成 html)
  • 引擎也有很多种,不同的编程语言有不同的实现,ruby 常用的引擎有 RedCloth

Liquid

Liquid is a Ruby library for rendering safe templates which cannot affect the security of the server they are rendered on.

Blog 中都是需要经过处理的,比如逻辑判断处理、循环处理,Jekyll 使用 Liquid 模板语言来进行处理。

  • 简单来说,凡是看到{{ }}或者{% %}包含的内容都是会被 Liquid 引擎处理的。比如"将日期格式化"的 liquid 语句:{{ post.date | date_to_string }}
  • 除了标准的 Liquid 语法外,jekyll 还扩展出了几个便利的方法~

>>>标准Liquid标记和过滤器
>>>Jekyll liquid扩展

Fork me on GitHub