API Reference Braces v#0.1.0

Copy Markdown View Source

Modules

Templates written in braces, {{ }}, in Elixir: rendered, compiled into your app, and converted from one language to another.

A template that can't be converted or rendered: description says what, and line (from

Django templates, rendered as Django renders them.

A Phoenix.Template engine for Django files. Only defined when phoenix_template is installed.

The filters, tests and operators of Jinja, Django, Nunjucks, Twig, Tera, Mailchimp, HubL and Klaviyo, which those languages' modules render with. They're Handlebars helpers, so a template converted to Handlebars renders with them too

Templates in any language rendered as safe HTML for Phoenix, such as a stored email template previewed in a LiveView. Only defined when phoenix_live_view is installed.

Handlebars templates in Elixir, rendered as Handlebars.js 4.7.10 renders them.

{{#path params hash}}program{{else}}inverse{{/path}}, an inverted {{^path}} block, or a {{{{raw}}}} block.

{{! … }} or {{!-- … --}}; value is the text inside.

Text between mustaches. original is the text as written and value the text after whitespace control.

{{* path params hash}}.

{{#* path params hash}}program{{/path}}.

The key=value pairs after a helper's params.

A mustache or sub-expression that is only key=value pairs, such as {{(a=b)}}.

One key=value pair.

{{path params hash}}; escaped is false for {{{…}}} and {{&…}}.

{{#> name params hash}}program{{/name}}.

{{> name params hash}}; indent is the whitespace before a standalone partial.

A path such as foo.bar, ../foo, this.foo or @index. head is the first part, or a sub-expression for (helper).foo; depth counts ../.

A list of statements: the template, or a block's body or {{else}} body. chained marks an {{else if …}} body.

A mix format plugin for Handlebars: .hbs and .handlebars files, and ~HBS sigils.

Handlebars rendered as safe HTML for Phoenix: Braces.HTML for Handlebars, which also takes an AST from Braces.Handlebars.parse/2. Only defined when phoenix_live_view is installed.

Custom helpers for Braces.Handlebars.render/3, written as Elixir functions.

The last argument of a custom helper (see Braces.Handlebars.Helpers), as Handlebars.js's options

A Handlebars template that doesn't parse. line counts from 1 and column from 0, in UTF-16 code units, as Handlebars.js reports them. description is Handlebars.js's message, and message adds the template's line with a caret under the error.

A Phoenix.Template engine for .hbs files. Only defined when phoenix_template is installed.

Prints a Handlebars AST in the debugging format of handlebars-parser's print, so an AST can be compared against Handlebars.js.

A template that can't be rendered with the data it was given, such as a missing value with strict: true or a helper that isn't defined. description is the message Handlebars.js gives for the same template and data where it gives one, except that a strict lookup names the object it missed data where Handlebars.js writes [object Object]. line counts from 1 and column from 0, in UTF-16 code units, at the tag or path that failed, in the partial named by partial when it failed in one. message adds the position and, when the template's source is known, its line with a caret under the error.

Text that Braces.Handlebars.render/3 writes without HTML escaping, even in {{value}}, like Handlebars.js's SafeString. Make one with Braces.Handlebars.safe/1. A {:safe, iodata} tuple, as Phoenix.HTML makes, is written without escaping too.

The ~HBS sigil: a Handlebars template compiled with your code, as HEEx compiles ~H. It gives a Braces.Handlebars.Template whose render function was generated from the template, so Braces.Handlebars.render/3 runs that code instead of reading the AST, and a path such as {{user.name}} looks up :user and :name in atom-keyed data without converting strings to atoms. It renders exactly as a template from Braces.Handlebars.compile/2 does.

A Handlebars template for Braces.Handlebars.render/3: its source, its parsed ast and, for a ~HBS template, render, the function compiled from it that renders it. Braces.Handlebars.compile/2 leaves render as nil, and render/3 reads the AST instead. to_string/1 gives the source.

HubSpot's HubL templates, its Jinja for emails and pages.

A Phoenix.Template engine for HubL files. Only defined when phoenix_template is installed.

The template that every language converts to and from: each language's parser reads its source into a Braces.IR, and each language's printer writes one out, so Braces.convert/2 converts from any language to any other.

Jinja templates, rendered as Jinja renders them.

A Phoenix.Template engine for .jinja files. Only defined when phoenix_template is installed.

Liquid templates, rendered as Liquid renders them.

A Phoenix.Template engine for .liquid files. Only defined when phoenix_template is installed.

Mailchimp's merge tags, *|FNAME|*, rendered as Mailchimp fills them in, with the merge fields as the data, by their tags' names.

A Phoenix.Template engine for Mailchimp files. Only defined when phoenix_template is installed.

Mustache templates, rendered as the Mustache spec (1.4) says.

A Mustache template that doesn't parse. description says what's wrong, line counts from 1 and column from 0, and message adds the template's line with a caret under the error.

A Phoenix.Template engine for .mustache files. Only defined when phoenix_template is installed.

A parsed Mustache template, from Braces.Mustache.compile/1: its source, and the parsed tree that Braces.Mustache.render/3 renders.

Mustachio templates, the language of Postmark's templates, rendered as Mustachio renders them.

A Phoenix.Template engine for Mustachio files. Only defined when phoenix_template is installed.

Nunjucks templates, Mozilla's Jinja for JavaScript, rendered as Nunjucks renders them.

A Phoenix.Template engine for Nunjucks files. Only defined when phoenix_template is installed.

The helpers of SendGrid's dynamic templates, which are Handlebars: render a SendGrid template as SendGrid sends it.

A compiled template in Liquid, Jinja, Django, Nunjucks, Twig, Tera, HubL, Mailchimp or Mustachio: from the language module's compile/2, or its sigil, such as ~JINJA, which compiles the template with your code.

Tera templates, the Jinja of Rust, rendered as Tera renders them.

A Phoenix.Template engine for Tera files. Only defined when phoenix_template is installed.

Twig templates, the Jinja of PHP's Symfony, Drupal and Craft, rendered as Twig renders them.

A Phoenix.Template engine for Twig files. Only defined when phoenix_template is installed.