* {{ post.published_at|date("m/d/Y") }} *
* {{ post.published_at|date_modify("-1day")|date("m/d/Y") }} *
* {% if date(user.created_at) < date('+2days') %} * {# do something #} * {% endif %} *
* {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %} * * {% set items = items|merge({ 'peugeot': 'car' }) %} * * {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #} *
* {{ [1, 2, 3]|join('|') }} * {# returns 1|2|3 #} * * {{ [1, 2, 3]|join }} * {# returns 123 #} *
* {{ "one,two,three"|split(',') }} * {# returns [one, two, three] #} * * {{ "one,two,three,four,five"|split(',', 3) }} * {# returns [one, two, "three,four,five"] #} * * {{ "123"|split('') }} * {# returns [1, 2, 3] #} * * {{ "aabbcc"|split('', 2) }} * {# returns [aa, bb, cc] #} *
* {# evaluates to true if the foo variable is null, false, or the empty string #} * {% if foo is empty %} * {# ... #} * {% endif %} *
* {# evaluates to true if the foo variable is an array or a traversable object #} * {% if foo is traversable %} * {# ... #} * {% endif %} *