Module z_template_compiler_runtime

Simple runtime for the compiled templates.

Copyright © 2016-2020 Marc Worrell

Behaviours: template_compiler_runtime.

Authors: Marc Worrell (marc@worrell.nl).

Description

Simple runtime for the compiled templates. Needs to be copied and adapted for different environments.

Function Index

builtin_tag/5Render image/image_url/media/url/lib tag.
cache_tag/6Render a block, cache the result for some time.
compile_map_nested_value/3Compile time mapping of nested value lookup.
custom_tag/4Render a custom tag (Zotonic scomp).
escape/2HTML escape a value.
find_nested_value/3Find a list of values at once, easier and more efficient than a nested find_value/4 Add pattern matching here for nested lookups.
find_nested_value/4Find a list of values at once, easier and more efficient than a nested find_value/4 Add pattern matching here for nested lookups.
find_value/4Find the value of key in some structure.
get_context_name/1
get_translations/2Fetch the translations for the given text.
is_modified/3Check if a file has been modified.
javascript_tag/3Render a script block, for Zotonic this is added to the scripts in the Context.
lookup_translation/3Find the best fitting translation.
map_template/3Dynamic mapping of a template to a template name, context sensitive on the template vars.
map_template_all/3Dynamically find all templates matching the template.
set_context_vars/2
spaceless_tag/3Remove spaces between HTML tags.
to_bool/2Convert a value to a boolean.
to_list/2Convert a value to a list.
to_render_result/3Convert a value to an iolist, used for converting values in {{ ...
to_simple_value/2Convert a value to something that can be handled as an argument to scomps.
to_simple_values/2Convert an argument list's values to something that can be handled as an argument to scomps.
trace_block/4Called when a block function is called.
trace_compile/4Called when compiling a module.
trace_render/3Called when a template is rendered (could be from an include).

Function Details

builtin_tag/5

builtin_tag(Tag::template_compiler:builtin_tag(), Expr::term(), Args::list(), Vars::map(), Context::term()) -> template_compiler:render_result()

Render image/image_url/media/url/lib tag. The Expr is the media item or dispatch rule.

cache_tag/6

cache_tag(MaxAge::integer(), Name::binary(), Args::list(), Fun::function(), TplVars::map(), Context::term()) -> template_compiler:render_result()

Render a block, cache the result for some time. Caching should be implemented by the runtime.

compile_map_nested_value/3

compile_map_nested_value(Tokens::list(), ContextVar::string(), Context::term()) -> NewTokens::list()

Compile time mapping of nested value lookup

custom_tag/4

custom_tag(Tag::atom(), Args::list(), Vars::map(), Context::term()) -> template_compiler:render_result()

Render a custom tag (Zotonic scomp)

escape/2

escape(Value::iodata() | undefined, Context::z:context()) -> iodata()

HTML escape a value

find_nested_value/3

find_nested_value(Ks, TplVars, Context) -> any()

Find a list of values at once, easier and more efficient than a nested find_value/4 Add pattern matching here for nested lookups.

find_nested_value/4

find_nested_value(V, Ks, TplVars, Context) -> any()

Find a list of values at once, easier and more efficient than a nested find_value/4 Add pattern matching here for nested lookups.

find_value/4

find_value(Key::term(), Vars::term(), TplVars::map(), Context::term()) -> term()

Find the value of key in some structure.

get_context_name/1

get_context_name(Context::term()) -> atom()

get_translations/2

get_translations(Text::binary(), Context::term()) -> binary() | z:trans()

Fetch the translations for the given text.

is_modified/3

is_modified(Filename::file:filename_all(), Mtime::calendar:datetime(), Context::term()) -> boolean()

Check if a file has been modified

javascript_tag/3

javascript_tag(Block::template_compiler:render_result(), TplVars::map(), Context::term()) -> template_compiler:render_result()

Render a script block, for Zotonic this is added to the scripts in the Context

lookup_translation/3

lookup_translation(Trans::z:trans(), TplVars::map(), Context::term()) -> binary()

Find the best fitting translation.

map_template/3

map_template(Template_file::template_compiler:template(), Vars::map(), Context::term()) -> {ok, template_compiler:template_file()} | {error, enoent | term()}

Dynamic mapping of a template to a template name, context sensitive on the template vars.

map_template_all/3

map_template_all(Template::template_compiler:template(), Vars::map(), Context::term()) -> [template_compiler:template_file()]

Dynamically find all templates matching the template

set_context_vars/2

set_context_vars(Args::map() | list(), Context::term()) -> term()

spaceless_tag/3

spaceless_tag(Value::template_compiler:render_result(), TplVars::map(), Context::term()) -> template_compiler:render_result()

Remove spaces between HTML tags

to_bool/2

to_bool(Value::term(), Context::term()) -> boolean()

Convert a value to a boolean.

to_list/2

to_list(Value::term(), Context::term()) -> list()

Convert a value to a list.

to_render_result/3

to_render_result(Value::term(), TplVars::map(), Context::term()) -> template_compiler:render_result()

Convert a value to an iolist, used for converting values in {{ ... }} expressions.

to_simple_value/2

to_simple_value(Value::term(), Context::term()) -> term()

Convert a value to something that can be handled as an argument to scomps.

to_simple_values/2

to_simple_values(Args::list(), Context::term()) -> list()

Convert an argument list's values to something that can be handled as an argument to scomps.

trace_block/4

trace_block(X1::{binary(), integer(), integer()}, Name::atom(), Module::atom(), Context::term()) -> ok | {ok, iodata(), iodata()}

Called when a block function is called

trace_compile/4

trace_compile(Module::atom(), Filename::binary(), Options::template_compiler:options(), Context::z:context()) -> ok

Called when compiling a module

trace_render/3

trace_render(Filename::binary(), Options::template_compiler:options(), Context::z:context()) -> ok | {ok, iodata(), iodata()}

Called when a template is rendered (could be from an include)


Generated by EDoc