x_component v0.1.0 X.Formatter View Source

X template formatted module.

Link to this section Summary

Functions

Formats given X template AST and returns template string.

Link to this section Types

Link to this type

options()

View Source
options() :: [nest: integer(), width: non_neg_integer() | :infinity]

Link to this section Functions

Link to this function

call(tree, options \\ [])

View Source
call([X.Ast.leaf()], options()) :: String.t()

Formats given X template AST and returns template string.

Options:

  • :nest - adds N leading whitespaces to every line of the formatted template. 0 by default.

Example

iex> X.Formatter.call(
...> [
...>   {{:tag_start, {1, 1}, 'div', [], nil, nil, false, false, false},
...>    [
...>      {{:tag_start, {6, 1}, 'span',
...>        [{:tag_attr, {12, 1}, 'class', 'test', false}], nil, nil, false, false,
...>        false},
...>       [
...>         {{:text_group, {25, 1}, 'span'},
...>          [{{:tag_output, {25, 1}, 'a ', true}, []}]}
...>       ]}
...>    ]}
...> ])
~s(
<div>
  <span class="test">{{ a }}</span>
</div>)