liquid用法笔记

liquid用法笔记

Liquid有两种标记类型:Output 和 Tag.

Hello flying Hello Hello tobi

Hello TOBI

Hello tobi has 4 letters!

Hello 2020 Oct

标准过滤器

date - 格式化时间
capitalize - 输出字符串,字符串(句子)首字母大写 e.g. 假设tb为"hello world" #=> 'Hello world'
downcase - 转换小写
upcase - 转换大写
first - 获取数组的第一个元素
last - 获取数组的最后一个元素
join - 用指定的字符拼接数组元素
sort - 排序数组
map - map/collect an array on a given property
size - 返回数组大小
escape - 转移字符串
escape_once - returns an escaped version of html without affecting existing escaped entities
strip_html - 除去字符串中的html标签?
strip_newlines - 除去字符串中的回车?
newline_to_br - 将所有的回车"\n" 转换成"\<br \/>"?
replace - 替换所有匹配内容 e.g.barbar #=> 'barbar'
replace_first - 替换第一个匹配内容 e.g.barfor #=> 'barfor'
remove - 移除所有匹配内容 e.g.barbar #=> 'barbar'
remove_first - 移除第一个匹配内容 e.g.barforbar #=> 'barforbar'
truncate - truncate a string down to x characters
truncatewords - truncate a string down to x words
prepend - 在字符串前面加上内容 e.g.farbar #=> 'farbar'
append - 字符串后面加上内容 e.g.barfoo#=> 'barfoo'
minus - 减法 e.g. 2 #=>2
plus - 加法 e.g. 6 #=> 6
times - 乘法 e.g. 20 #=> 20
divided_by - 除法 e.g. 5 #=> 5
split - 分割字符串 e.g.ab #=> ['a','b']
modulo - 取余 e.g. 1 #=> 1

In Handlebars, will be HTML-escaped, but } will not.