Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
update template syntax docs
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Jan 29, 2012
1 parent 69ff32e commit c7be540
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/syntax.md
Expand Up @@ -15,9 +15,15 @@ Swig uses the same template syntax as Django Templates
Variables <a name="variables" href="#variables">#</a>
---------

Used to print a variable to the template. If the variable is not in the context we don't get an error, rather an empty string. You can use dot notation to access object proerties or array memebers.
Used to print a variable to the template. If the variable is not in the context we don't get an error, rather an empty string. You can use dot notation to access object properties or array memebers.

<p>First Name: {{ users.0.first_name }}</p>
<h1>{{ title }}</h1>
First Name: {{ users[0].first_name }}

You can also use in-context variables as keys on arrays and objects:
Assume context to the template is `{ users: ['Paul', 'Jim', 'Jane'], key: 2 }`

{{ users[key] }}

Variables also are able to be transformed via [filters](filters.md).

Expand All @@ -26,7 +32,7 @@ By default, all variables will be escaped for safe HTML output. For more informa
Comments <a name="comments" href="#domments">#</a>
--------

Comment tags are simply ignored. Comments can't span multitple lines.
Comment tags are simply ignored by the parser. They will removed before your templates are rendered so that no one can see them unless they have access to your source code.

{# This is a comment #}

Expand Down

0 comments on commit c7be540

Please sign in to comment.