Slash::Display - Display library for Slash
slashDisplay('some template', { key => $val });
my $text = slashDisplay('template', \%data, 1);
Slash::Display uses Slash::Display::Provider to provide the template data from the Slash::DB API.
It will process and display a template using the data passed in. In addition to whatever data is passed in the hashref, the contents of the user, form, and static objects, as well as the %ENV hash, are available.
slashDisplay will print by default to STDOUT, but will
instead return the data if the third parameter is true. If the fourth
parameter is true, HTML comments surrounding the template will NOT
be printed or returned. That is, if the fourth parameter is false,
HTML comments noting the beginning and end of the template will be
printed or returned along with the template.
Template for more information about templates.
Processes a template.
_populate).
1 instead of a hashref, that will
be the same as if the hashref were { Return => 1 }.
Section will also default first to ``light'' if the user is in light mode (and fall back to ``default,'' again, if no template for the ``light'' section exists).
A Section value of ``NONE'' will cause no section to be defined, so ``default'' will be used.
A Page value of ``NONE'' will cause no page to be defined, so ``misc'' will be used.
Return a Template object.
_populate(DATA)Put universal data stuff into each template: constants, user, form, env.
Each can be overriden by passing a hash key of the same name to
slashDisplay.
The template has the options PRE_CHOMP and POST_CHOMP set by default. You can change these in the vars table in your database (template_pre_chomp, template_post_chomp). Also look at the template_cache_size variable for setting the cache size. Template for more information. The cache will be disabled entirely if cache_enabled is false.
The template provider is Slash::Display::Provider, and the plugin module Slash::Display::Plugin can be referenced by simply ``Slash''.
Additional scalar ops (which are global, so they are in effect
for every Template object created, from this or any other module)
include uc, lc, ucfirst, and lcfirst,
which all do what you think.
[% myscalar.uc %] # return upper case myscalar
Additional list ops include rand, which returns a random element
from the given list.
[% mylist.rand %] # return single random element from mylist
Also provided are some filters. The fixurl, fixparam, fudgeurl,
and strip_* filters are just frontends to the functions of those
names in the Slash API:
[% FILTER strip_literal %]
I think that 1 > 2!
[% END %]
(Note that [% var | filter %] is a synonym for [% FILTER filter; var; END %].)
<A HREF="[% env.script_name %]?op=[% form.op | fixparam %]">
Each strip_* function in Slash::Utility is also available as a filter. It might seem simpler to just use the functional form:
[% form.something | strip_nohtml %]
[% Slash.strip_nohtml(form.something) %]
But we might make it harder to use the Slash plugin (see the Slash::Display::Plugin manpage) in the future (perhaps only certain seclevs?), so it is best to stick with the filter, which is probably faster, too.
Template(3), Slash(3), Slash::Utility(3), Slash::DB(3), Slash::Display::Plugin(3), Slash::Display::Provider(3).