EEx.SmartEngine

EEx.SmartEngine

EEx使用的默认引擎。

它包括@foo未来的分配(如)和其他可能的便利。

实例

iex> EEx.eval_string("<%= @foo %>", assigns: [foo: 1]) "1"

在上面的例子中,我们可以访问该值foo的结合下assigns使用@foo。这非常有用,因为模板在编​​译后可以接收不同的赋值,并且不需要为每个变量集重新编译。

在编译到函数时,也可以使用赋值:

# sample.eex <%= @a + @b %> # sample.ex defmodule Sample do require EEx EEx.function_from_file :def, :sample, "sample.eex", [:assigns] end # iex Sample.sample(a: 1, b: 2) #=> "3"

摘要

功能

handle_begin(quoted)

回调实现EEx.Engine.handle_begin/1

handle_body(quoted)

回调实现EEx.Engine.handle_body/1

handle_end(quoted)

回调实现EEx.Engine.handle_end/1

handle_expr(buffer, marker, expr)

回调实现EEx.Engine.handle_expr/3

handle_text(buffer, text)

回调实现EEx.Engine.handle_text/2

init(opts)

回调实现EEx.Engine.init/1

功能

handle_begin(quoted)

回调实现EEx.Engine.handle_begin/1...

handle_body(quoted)

回调实现EEx.Engine.handle_body/1...

handle_end(quoted)

回调实现EEx.Engine.handle_end/1...

handle_expr(buffer, marker, expr)

回调实现EEx.Engine.handle_expr/3...

handle_text(buffer, text)

回调实现EEx.Engine.handle_text/2...

init(opts)

Callback implementation for EEx.Engine.init/1.