Skip to content

Implementation Notes

John Albin Wilkins edited this page Apr 8, 2021 · 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

Built-in 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
  • 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 Functions:

  • attribute: ???
  • block: ??
  • constant: ??
  • cycle: ??
  • date: ??
  • dump: ??
  • html_classes: ??
  • include: Throws error: "include function does not exist and is not defined in the context" https://github.com/twigjs/twig.js/issues/392
  • max: ??
  • min: ??
  • parent: ??
  • random: ??
  • range: ??
  • source: ??
  • country_timezones: ??
  • template_from_string: ??

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