- first
- last
Liquid filters: first, last
first or last
- character in a string
- element in an array, a vector, or a tuple
examples/liquid/liquid-filters-order/src/main.rs
fn main() { let template = liquid::ParserBuilder::with_stdlib() .build() .unwrap() .parse( " plain: {{text}} first: {{text | first}} last: {{text | last}} plain: {{words}} first: {{words | first}} last: {{words | last}} plain: {{numbers}} first: {{numbers | first}} last: {{numbers | last}} plain: {{tpl}} first: {{tpl | first}} last: {{tpl | last}} ", ) .unwrap(); let text = "This is some text"; let words = ["These", "are", "words", "in", "an", "array"]; let numbers = vec![7, 3, 19, 4]; let tpl = ("foo", 42, "bar", 3.4); let globals = liquid::object!({ "text": text, "words": words, "numbers": numbers, "tpl": tpl, }); let output = template.render(&globals).unwrap(); println!("{}", output); }
plain: This is some text first: T last: t plain: Thesearewordsinanarray first: These last: array plain: 73194 first: 7 last: 4 plain: foo42bar3.4 first: foo last: 3.4