View Source template_compiler (template_compiler v2.10.0)
Link to this section Summary
Functions
Compile a in-memory template to a module.
Compile a template to a module. The template is the path of the template to be compiled.
Remove all template lookups, forces recheck.
Ping that a template has been changed
Ping that a template has been changed
Extract compiler options and handle possible defaults.
Check if the modulename looks like a module generated by the template compiler.
Find the module of a compiled template, if not yet compiled then compile the template.
Render a template. This looks up the templates needed, ensures compilation and returns the rendering result.
Render a template. This looks up the templates needed, ensures compilation and returns the rendering result. Start with a block-map to find some predefined blocks.
Render a named block, defined in a template
Fetch all translatable strings from a template.
Link to this section Types
-type block_element() :: {block, identifier_token(), elements()}.
-type builtin_tag() :: image | image_url | image_data_url | media | url | lib.
-type element() :: block_element() | true | false | undefined | term().
-type elements() :: [element()].
-type identifier_token() :: {identifier, linecol(), binary()}.
-type linecol() :: {Line :: integer(), Column :: integer(), file:filename_all()}.
-type model_return() :: {ok, {term(), list()}} | {error, term()}.
-type option() ::
{runtime, atom()} |
{context_name, term()} |
{trace_position, {Filename :: binary(), Line :: integer(), Col :: integer()}} |
{context_vars, [binary()]}.
-type options() :: [option()].
-type render_result() :: binary() | string() | term() | [render_result()].
-type template() :: binary() | string() | {cat, binary() | string()} | {cat, binary() | string(), term()} | {overrules, binary() | string(), file:filename_all()} | template_file().
-type template_file() :: #template_file{}.
-type template_key() :: {ContextName :: term(), Runtime :: atom(), template()}.
-type translation_message() :: {Text :: binary(), Args :: proplists:proplist(), {Filename :: file:filename(), Line :: pos_integer(), Column :: pos_integer()}}.
Link to this section Functions
-spec compile_binary(binary(), file:filename_all(), options(), term()) -> {ok, atom()} | {error, term()}.
-spec compile_blocks([block_element()], #cs{}) -> {#ws{}, [{atom(), erl_syntax:syntaxTree(), #ws{}}]}.
-spec compile_file(file:filename_all(), options(), term()) -> {ok, atom()} | {error, term()}.
-spec flush() -> ok.
-spec flush_context_name(ContextName :: term()) -> ok.
-spec flush_file(file:filename_all()) -> ok.
-spec get_option(Option :: atom(), Options :: options()) -> term().
-spec is_template_module(binary() | string() | atom()) -> boolean().
-spec lookup(binary(), options(), term()) -> {ok, atom()} | {error, term()}.
-spec render(Template :: template(), Vars :: map() | list(), Options :: options(), Context :: term()) -> {ok, render_result()} | {error, term()}.
-spec render(Template :: template(), BlockMap :: map(), Vars :: map() | list(), Options :: options(), Context :: term()) -> {ok, render_result()} | {error, term()}.
-spec render_block(Block :: atom(), Template :: template(), Vars :: map() | list(), Options :: options(), Context :: term()) -> {ok, render_result()} | {error, term()}.
-spec translations(file:filename_all()) -> {ok, [translation_message()]} | {error, term()}.