Skip to content

Implementation Notes

Dorian Marchal edited this page Feb 27, 2020 · 35 revisions

Differences / Implementation Notes

  • currently twig.js does not have the same auto-escaping that Twig does.

Feature Support

Built-in Tags:

  • autoescape:
  • block: Supported
  • do:
  • embed: Supported
  • extends: Supported
  • filter: Supported
  • flush: N/A
  • for: Supported
  • from: Supported
  • if: Supported
  • import: Supported
  • include: Supported
  • macro: Supported
  • sandbox:
  • set: Supported
  • spaceless: Supported
  • use: Supported
  • verbatim: Supported
  • with: Supported

Filters

  • abs: Supported
  • batch: Supported
  • capitalize: Supported
  • convert_encoding: N/A
  • date: Supported
  • date_modify: Supported
  • default: Supported
  • escape: Supported
  • first: Supported
  • format: Supported
  • join: Supported
  • json_encode: Supported
  • keys: Supported
  • last: Supported Note: Doesn't work for numbers. E.g. {{ 14|last }} returns '' instead of 4.
  • length: Supported
  • lower: Supported
  • merge: Supported
  • nl2br: Supported
  • number_format: Supported
  • raw:
  • replace: Supported
  • reverse: Supported
  • round: Supported
  • slice: Supported
  • sort: Supported
  • split: Supported
  • striptags: Supported
  • title: Supported
  • trim: Supported
  • upper: Supported
  • url_encode: Supported

Built-in Tests:

  • constant:
  • defined: Supported
  • divisibleby: Supported
  • empty: Supported
  • even: Supported
  • iterable: Supported
  • null / none: Supported
  • odd: Supported
  • sameas: Supported

Built-in Operators:

  • in: Supported
  • is: Supported
  • Math (+, -, /, %, *, **): Supported
  • Logic (and, or, not, ()): Supported
  • Bitwise (b-and, b-or, b-xor): Supported
  • Comparisons (==, !=, <, >, >=, <=, ===): Supported
  • Others (.., |, ~, ., [], ?:): Supported
  • Null-coalescing (??): Supported
Clone this wiki locally