Jennie.Tokeniser (jennie v0.9.0)

Turns a template string into a flat list of tokens.

Tokens are one of:

  • {:text, binary, line, col}
  • {:tag, type, payload, line, col}

where type is one of :var, :unescaped, :section, :inverted, :close, :comment, :partial, :delimiter. The payload is:

  • {:var | :unescaped, keys}keys is the dotted name split on "."

  • {:section | :inverted | :close, keys}

  • {:partial, name} — the raw (unsplit) partial name
  • {:comment, _} / {:delimiter, _} — content is irrelevant to output

Set-delimiter tags ({{=<% %>=}}) are applied during scanning so subsequent tags use the new delimiters.

Summary

Functions

Tokenise source, returning {:ok, tokens} or raising Jennie.SyntaxError.

Functions

tokenise(source)

@spec tokenise(String.t()) :: {:ok, [tuple()]}

Tokenise source, returning {:ok, tokens} or raising Jennie.SyntaxError.