Module z_template

Template handling, compiles and renders django compatible templates using an extended version of erlydtl.

Copyright 2009-2012 Marc Worrell

Behaviours: gen_server.

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

Description

Template handling, compiles and renders django compatible templates using an extended version of erlydtl

Function Index

code_change/3
compile/2Compile a template, return the module name.
filename_to_modulename/2Translate a filename to a module name.
filename_to_modulename/3
find_template/2Finds the template designated by the file, check modules.
find_template/3Finds the first or all templates designated by the file, check modules.
find_template_cat/3Finds the template designated by the file, for the category of the rsc with id, check modules.
handle_call/3Compile the template if it has been modified, return the template module for rendering.
handle_cast/2Reset all compiled templates, done by the module_indexer after the module list changed.
handle_info/2
init/1Initialize the template server, handles template compiles and rendering.
is_template_module/1Check if the module is a template module.
module_reindexed/2Observer, triggered when there are new module files indexed.
render/2
render/3Render a template.
render_to_iolist/3Render a template to an iolist().
reset/1Force a reset of all templates, used after a module has been activated or deactivated.
start_link/1
terminate/2

Function Details

code_change/3

code_change(OldVersion, State, Extra) -> any()

compile/2

compile(File, Context) -> {ok, atom()} | {error, Reason}

Compile a template, return the module name.

filename_to_modulename/2

filename_to_modulename(File::file:filename(), Context::#context{}) -> string()

Translate a filename to a module name

filename_to_modulename/3

filename_to_modulename(File::file:filename(), UAClass::ua_classifier:device_type(), Host::atom()) -> string()

find_template/2

find_template(Module_index::File, Context) -> {ok, filename()} | {ok, #module_index{}} | {error, code}

Finds the template designated by the file, check modules. When the file is tagged with 'abs' path, then do nothing and assume the file exists.

find_template/3

find_template(File, X2::All, Context) -> [#module_index{}]

Finds the first or all templates designated by the file, check modules.

find_template_cat/3

find_template_cat(File, Id, Context) -> {ok, filename()} | {error, code}

Finds the template designated by the file, for the category of the rsc with id, check modules. When the file is an absolute path, then do nothing and assume the file exists.

handle_call/3

handle_call(X1::{check_modified, Module}, From, State) -> ok | modified

Compile the template if it has been modified, return the template module for rendering.

handle_cast/2

handle_cast(Msg, State) -> any()

Reset all compiled templates, done by the module_indexer after the module list changed.

handle_info/2

handle_info(Msg, State) -> any()

init/1

init(SiteProps::Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initialize the template server, handles template compiles and rendering.

is_template_module/1

is_template_module(Module::atom()) -> bool()

Check if the module is a template module.

module_reindexed/2

module_reindexed(X1, Context) -> any()

Observer, triggered when there are new module files indexed

render/2

render(Render, Context) -> any()

render/3

render(Module_index::File, Variables, Context) -> list()

Render a template. First requests the template module from the template server, then renders the template. The resulting list contains the rendered template and scomp contexts. Use render_to_iolist/3 to get a iolist().

render_to_iolist/3

render_to_iolist(File, Vars, Context) -> {iolist(), Context}

Render a template to an iolist(). This removes all scomp state etc from the rendered html and appends the information in the scomp states to the context for later rendering.

reset/1

reset(Host) -> any()

Force a reset of all templates, used after a module has been activated or deactivated.

start_link/1

start_link(SiteProps) -> any()

terminate/2

terminate(Reason, State) -> any()


Generated by EDoc, Oct 31 2014, 17:54:27.