mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
feature: concat filter
This commit is contained in:
@@ -45,6 +45,44 @@ describe('filters', function () {
|
||||
it('should return "184" for 183.357', () => test('{{ 183.357 | ceil }}', '184'))
|
||||
})
|
||||
|
||||
describe('concat', function () {
|
||||
it('should concat arrays', () => test(`
|
||||
{%- assign fruits = "apples, oranges, peaches" | split: ", " -%}
|
||||
{%- assign vegetables = "carrots, turnips, potatoes" | split: ", " -%}
|
||||
|
||||
{%- assign everything = fruits | concat: vegetables -%}
|
||||
|
||||
{%- for item in everything -%}
|
||||
- {{ item }}
|
||||
{% endfor -%}`,
|
||||
`- apples
|
||||
- oranges
|
||||
- peaches
|
||||
- carrots
|
||||
- turnips
|
||||
- potatoes
|
||||
`))
|
||||
it('should support chained concat', () => test(`
|
||||
{%- assign fruits = "apples, oranges, peaches" | split: ", " -%}
|
||||
{%- assign vegetables = "carrots, turnips, potatoes" | split: ", " -%}
|
||||
{%- assign furniture = "chairs, tables, shelves" | split: ", " -%}
|
||||
{%- assign everything = fruits | concat: vegetables | concat: furniture -%}
|
||||
|
||||
{%- for item in everything -%}
|
||||
- {{ item }}
|
||||
{% endfor -%}`,
|
||||
`- apples
|
||||
- oranges
|
||||
- peaches
|
||||
- carrots
|
||||
- turnips
|
||||
- potatoes
|
||||
- chairs
|
||||
- tables
|
||||
- shelves
|
||||
`))
|
||||
})
|
||||
|
||||
describe('date', function () {
|
||||
it('should support date: %a %b %d %Y', function () {
|
||||
var str = ctx.date.toDateString()
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ describe('tokenizer', function () {
|
||||
expect(tokens[1].type).to.equal('value')
|
||||
expect(tokens[1].value).to.equal('foo | date: "%Y-%m-%d"')
|
||||
})
|
||||
it('should handle successive value and tags', function () {
|
||||
it('should handle consecutive value and tags', function () {
|
||||
var html = '{{foo}}{{bar}}{%foo%}{%bar%}'
|
||||
var tokens = parse(html)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user