~ubuntu-branches/ubuntu/precise/grantlee/precise

« back to all changes in this revision

Viewing changes to dox/builtins.dox

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2010-06-11 23:41:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100611234145-oas7rhdrbwy8j55c
Tags: upstream-0.1.1
ImportĀ upstreamĀ versionĀ 0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
namespace Grantlee
 
3
{
 
4
/**
 
5
  @page builtins Builtin tags and filters.
 
6
 
 
7
  @section django_builtins Tags and filters ported from Django
 
8
 
 
9
  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.
 
10
 
 
11
  @section grantlee_extras Additional tags available in Grantlee
 
12
 
 
13
  %Grantlee also provides some extra tags not available in DJango.
 
14
 
 
15
  @subsection media_finder_tag media_finder
 
16
 
 
17
  Queries %Grantlee for a complete URL, given a target name.
 
18
 
 
19
  This tag can typically be used to insert a URL for an image, external script or CSS file, or other external media.
 
20
 
 
21
  @code
 
22
    <img src="{% media_finder "someimage.png" %}" />
 
23
  @endcode
 
24
 
 
25
  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.
 
26
 
 
27
  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.
 
28
 
 
29
  It is the responsibility of the caller to copy the media to the <tt>/home/user/myoutput_media/</tt> directory.
 
30
 
 
31
  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.
 
32
 
 
33
  @subsection range_tag range
 
34
 
 
35
  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>.
 
36
 
 
37
  Create a list from 0 to 5:
 
38
  @code
 
39
    <ul>
 
40
    {% range 5 as num %}
 
41
      <li>{{ num }}
 
42
    {% endrange %}
 
43
    </ul>
 
44
  @endcode
 
45
 
 
46
  Create a list from 5 to 10:
 
47
  @code
 
48
    <ul>
 
49
    {% range 5 10 as num %}
 
50
      <li>{{ num }}
 
51
    {% endrange %}
 
52
    </ul>
 
53
  @endcode
 
54
 
 
55
  Create a list from 5 to 50 with a step of 5:
 
56
  @code
 
57
    <ul>
 
58
    {% range 5 50 5 as num %}
 
59
      <li>{{ num }}
 
60
    {% endrange %}
 
61
    </ul>
 
62
  @endcode
 
63
 
 
64
  The range tag can also be used without arguments:
 
65
 
 
66
  @code
 
67
    {% range rating %}
 
68
      <img src="{% media_finder "star.png" %}" />
 
69
    {% endrange %}
 
70
  @endcode
 
71
 
 
72
*/
 
73
}