KTextTemplate
Tags and filters ported from Django
See the Builtins documentation for Django 1.9 for an overview of the builtin tags and filters available in KTextTemplate. Almost all tags and filter in django are available in KTextTemplate. Exceptions are the url tag
, because KTextTemplate does not have a views system. Additionally the ssi
tag is disabled because of potential security risks. The dictdort
, dictsortreversed
, filesizeformat
, iriencode
, phone2numeric
, pluralize
, pprint
, title
, truncatewords_html
, urlencode
, urlize
and urlizetrunc
filters have not yet been ported due to time constraints.
Additional tags available in KTextTemplate
KTextTemplate also provides some extra tags not available in Django.
media_finder
Queries KTextTemplate for a complete URL, given a target name.
This tag can typically be used to insert a URL for an image, external script or CSS file, or other external media.
The media_finder
tag retrieves the result through Engine::mediaUri, which in turn queries the TemplateLoaders for the URL to return via the AbstractTemplateLoader::getMediaUri interface.
It is possible to configure whether absolute or relative urls are created by using the Context::setUrlType method. If the path to external media is not the same as the path to the template, the Context::setRelativeMediaPath method can be used to specify a relative base path. For example, if creating a template /home/user/myoutput.html
which references someimage.png
, the path "myoutput_media/"
can be set so that the {% media_finder %}
puts the path myoutput_media/someimage.png
into the template. This way the output and the media it references are portable together.
It is the responsibility of the caller to copy the media to the /home/user/myoutput_media/
directory.
with media_prefix
defined to nothing when creating output with absolute urls, and something like "media/"
if creating output with relative urls and external media should be available in the media/
subdirectory.
range
Loops over a range in a manner similar to the python builtin of the same name.
Create a list from 0 to 5:
Create a list from 5 to 10:
Create a list from 5 to 50 with a step of 5:
The range tag can also be used without arguments:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.