c965048f40
* Fine tune whitespace The EEx outut now emits more human-readable and predictable formatting. This includes proper indenting, at least for each "root" template. * Internal whitespace control You can now use a bang version of any nonvoid tag to emit the markup witout the internal whitespace. This means that there will not be a newline emitted after the opening tag and before the closing tag.
31 lines
725 B
Elixir
31 lines
725 B
Elixir
defmodule Temple.Parser.RightArrow do
|
|
@moduledoc false
|
|
alias Temple.Parser
|
|
|
|
@behaviour Parser
|
|
|
|
defstruct elixir_ast: nil, children: []
|
|
|
|
@impl Parser
|
|
def applicable?({:->, _, _}), do: true
|
|
def applicable?(_), do: false
|
|
|
|
@impl Parser
|
|
def run({_, _, [[pattern], args]}) do
|
|
children = Parser.parse(args)
|
|
|
|
Temple.Ast.new(__MODULE__, elixir_ast: pattern, children: children)
|
|
end
|
|
|
|
defimpl Temple.Generator do
|
|
def to_eex(%{elixir_ast: elixir_ast, children: children}, indent \\ 0) do
|
|
[
|
|
"#{Parser.Utils.indent(indent)}<% ",
|
|
Macro.to_string(elixir_ast),
|
|
" -> %>\n",
|
|
for(child <- children, do: Temple.Generator.to_eex(child, indent + 1))
|
|
]
|
|
end
|
|
end
|
|
end
|