Module z_template

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

Copyright © 2009 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, retun the module name.
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.
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, retun the module name.

find_template/2

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

Finds the template designated by the file, check modules. When the file is an absolute path, then do nothing and assume the file exists.

find_template/3

find_template(File, X2::All, Context) -> FilenameList

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, File}, From, State) -> {ok, Module} | {error, Reason}

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.

render/3

render(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(Context) -> 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, Feb 25 2011, 21:14:41.