name -- template file name or file-like object
from_string -- if True treat name as a string containing the
template data instead of a file to read from
auto_reload -- if the template has not been checked in this
many seconds then check it and reload if there
are any changes. If None only load the
template file once.
Checking and reloading is done by the
start_file() function.
Ignored if from_string is True or if name is a
file-like object.
allow_degenerate -- If True then template is allowed to not
have a {contents}...{/contents} block. In this
case the entire file is available as a layer
called '*'. eg. l = tmpl.format('*', ...)
name -- template file name or file-like object
from_string -- if True treat name as a string containing the
template data instead of a file to read from
auto_reload -- if the template has not been checked in this
many seconds then check it and reload if there
are any changes. If None only load the
template file once.
Checking and reloading is done by the
start_file() function.
Ignored if from_string is True or if name is a
file-like object.
allow_degenerate -- If True then template is allowed to not
have a {contents}...{/contents} block. In this
case the entire file is available as a layer
called '*'. eg. l = tmpl.format('*', ...)
template -- template object for generating this layer
header -- text before the content of this layer
footer -- text after the content of this layer
This constructor should not be called directly. Use
the open() function in a FileLayer or the open_layer()
function in another Layer object to create a new Layer.
HTML markup is expanded recursively. Each of the content
values below are passed to expand_html_markup again before
applying the operation on the right:
string or unicode string -> HTML-escaped version of string
[content1, content2, ...] -> concatenate content1, content2, ...
('join',list,sep) -> join items in list with seperator sep
('pluralize',count,singular_content,plural_content)
-> if count == 1 use singular_content,
otherwise use plural_content
('urljoin',head,tail) -> join safe url head with unsafe url-ending tail
('href',link,content) -> HTML href to link wrapped around content
('target',name) -> HTML target name
('br',) -> HTML line break
('br',count) -> HTML line break * count
('p',) -> HTML paragraph break
('p',content) -> HTML paragraph
('i',content) -> italics
('b',content) -> bold
('u',content) -> underline
('&',entity) -> HTML entity (entity has no & or ;)
RawHTML(value) -> value unmodified
django_form(form, errors=True, join_errors=<function <lambda> at 0x40247374>)
Converts a django FormWrapper object to a dictionary that
can be used by Templayer. Each field is rendered into a
%form.NAME% slot.
If errors is True then this function will also render
errors into %form.NAME.errors% slots.
When there is more than one error on a single field the
errors will be joined with the join_errors function.
The default join_errors function puts a newline between each
error.
eg:
If tmpl is an HTMLTemplate object with a {form_layer} layer
and form is a FormWrapper object with username and password
fields, then this code will fill the {form_layer} layer's
%title%, %form.username%, %form.password%,
%form.username.errors% and %form.password.errors% slots: