File: builtins.dox

package info (click to toggle)
grantlee5 5.1.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,152 kB
  • sloc: cpp: 24,299; python: 413; sh: 108; ruby: 24; makefile: 20
file content (73 lines) | stat: -rw-r--r-- 3,172 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

namespace Grantlee
{
/**
  @page builtins Builtin tags and filters.

  @section django_builtins Tags and filters ported from Django

  See the <a href="http://docs.djangoproject.com/en/1.1/ref/templates/builtins/">Builtins documentation for Django 1.1</a> for an overview of the builtin tags and filters available in %Grantlee. Almost all tags and filter in django are available in %Grantlee. Exceptions are <a href="http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#url">the url tag</a>, because %Grantlee 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.

  @section grantlee_extras Additional tags available in Grantlee

  %Grantlee also provides some extra tags not available in DJango.

  @subsection media_finder_tag media_finder

  Queries %Grantlee 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.

  @code
    <img src="{% media_finder "someimage.png" %}" />
  @endcode

  The media_finder tag retrieves the result through Engine::mediaUri, which in turn queries the TemplateLoaders for the URL to return via the TemplateLoader::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 <tt>/home/user/myoutput.html</tt> which references someimage.png, the path "myoutput_media/" can be set so that the @gr_tag{media_finder} puts the path <tt>myoutput_media/someimage.png</tt> 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 <tt>/home/user/myoutput_media/</tt> directory.

  with <tt>media_prefix</tt> defined to nothing when creating output with absolute urls, and something like <tt>"media/"</tt> if creating output with relative urls and external media should be available in the <tt>media/</tt> subdirectory.

  @subsection range_tag range

  Loops over a range in a manner similar to the <a href="http://docs.python.org/library/functions.html#range">python builtin of the same name</a>.

  Create a list from 0 to 5:
  @code
    <ul>
    {% range 5 as num %}
      <li>{{ num }}
    {% endrange %}
    </ul>
  @endcode

  Create a list from 5 to 10:
  @code
    <ul>
    {% range 5 10 as num %}
      <li>{{ num }}
    {% endrange %}
    </ul>
  @endcode

  Create a list from 5 to 50 with a step of 5:
  @code
    <ul>
    {% range 5 50 5 as num %}
      <li>{{ num }}
    {% endrange %}
    </ul>
  @endcode

  The range tag can also be used without arguments:

  @code
    {% range rating %}
      <img src="{% media_finder "star.png" %}" />
    {% endrange %}
  @endcode

*/
}