meex v1.4.0 MEEx.SmartEngine
The default engine used by MEEx.
It includes assigns (like @foo
) and possibly other
conveniences in the future.
Examples
iex> MEEx.eval_string("{%= @foo %}", assigns: [foo: 1])
"1"
In the example above, we can access the value foo
under
the binding assigns
using @foo
. This is useful because
a template, after being compiled, can receive different
assigns and would not require recompilation for each
variable set.
Assigns can also be used when compiled to a function:
# sample.mex
{%= @a + @b %}
# sample.ex
defmodule Sample do
require MEx
MEEx.function_from_file :def, :sample, "sample.mex", [:assigns]
end
# iex
Sample.sample(a: 1, b: 2) #=> "3"
Summary
Functions
Callback implementation for MEEx.Engine.handle_body/1
Callback implementation for MEEx.Engine.handle_expr/3
Callback implementation for MEEx.Engine.handle_text/2
Callback implementation for MEEx.Engine.init/1
Functions
Callback implementation for MEEx.Engine.handle_body/1
.
Callback implementation for MEEx.Engine.handle_expr/3
.
Callback implementation for MEEx.Engine.handle_text/2
.
Callback implementation for MEEx.Engine.init/1
.