Permalink
Browse files

update template syntax docs

  • Loading branch information...
1 parent 69ff32e commit c7be5409d9d36002fc9c0c9b3c42dece930be865 @paularmstrong committed Jan 29, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 docs/syntax.md
View
@@ -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).
@@ -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 #}

0 comments on commit c7be540

Please sign in to comment.