3912 lines
89 KiB
Text
Generated
3912 lines
89 KiB
Text
Generated
'======================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'Designer Documentation' Generic.Heading
|
|
'\n' Text
|
|
|
|
'======================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'This part of the Jinja documentaton is meant for template designers.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Basics' Generic.Heading
|
|
'\n' Text
|
|
|
|
'======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'The Jinja template language is designed to strike a balance between content' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'and application logic. Nevertheless you can use a python like statement' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"language. You don't have to know how Python works to create Jinja templates," Text
|
|
'\n' Text.Whitespace
|
|
|
|
'but if you know it you can use some additional statements you may know from' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'Python.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Here is a small example template' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n' Comment.Preproc
|
|
|
|
' ' Text
|
|
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'html' Name.Tag
|
|
' ' Text
|
|
'xmlns' Name.Attribute
|
|
'=' Operator
|
|
'"http://www.w3.org/1999/xhtml"' Literal.String
|
|
' ' Text
|
|
'lang' Name.Attribute
|
|
'=' Operator
|
|
'"en"' Literal.String
|
|
' ' Text
|
|
'xml:lang' Name.Attribute
|
|
'=' Operator
|
|
'"en"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'head' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'title' Name.Tag
|
|
'>' Punctuation
|
|
'My Webpage' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'title' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'head' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'body' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'ul' Name.Tag
|
|
' ' Text
|
|
'id' Name.Attribute
|
|
'=' Operator
|
|
'"navigation"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'navigation' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'<' Punctuation
|
|
'a' Name.Tag
|
|
' ' Text
|
|
'href' Name.Attribute
|
|
'=' Operator
|
|
'"' Literal.String
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'item' Name.Variable
|
|
'.href' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'item' Name.Variable
|
|
'.caption' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'a' Name.Tag
|
|
'>' Punctuation
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'My Webpage' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'variable' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'body' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'html' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'This covers the default settings. The application developer might have changed' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'the syntax from ' Text
|
|
'``' Literal.String
|
|
'{% foo %}' Literal.String
|
|
'``' Literal.String
|
|
' to ' Text
|
|
'``' Literal.String
|
|
'<% foo %>' Literal.String
|
|
'``' Literal.String
|
|
' or something similar. This' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'documentation just covers the default values.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'A variable looks like ' Text
|
|
'``' Literal.String
|
|
'{{ foobar }}' Literal.String
|
|
'``' Literal.String
|
|
' where foobar is the variable name. Inside' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'of statements (' Text
|
|
'``' Literal.String
|
|
'{% some content here %}' Literal.String
|
|
'``' Literal.String
|
|
') variables are just normal names' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'without the braces around it. In fact ' Text
|
|
'``' Literal.String
|
|
'{{ foobar }}' Literal.String
|
|
'``' Literal.String
|
|
' is just an alias for' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'the statement ' Text
|
|
'``' Literal.String
|
|
'{% print foobar %}' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Variables are coming from the context provided by the application. Normally there' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'should be a documentation regarding the context contents but if you want to know' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'the content of the current context, you can add this to your template' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'pre' Name.Tag
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'debug' Name.Variable
|
|
'(' Operator
|
|
')' Operator
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'pre' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
"A context isn't flat which means that each variable can has subvariables, as long" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'as it is representable as python data structure. You can access attributes of' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'a variable using the dot and bracket operators. The following examples show' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'this' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.username' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' is the same as\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'[' Operator
|
|
"'username'" Literal.String.Single
|
|
']' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' you can also use a variable to access an attribute:\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'users' Name.Variable
|
|
'[' Operator
|
|
'current_user' Name.Variable
|
|
']' Operator
|
|
'.username' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' If you have numerical indices you have to use the [] syntax:\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'users' Name.Variable
|
|
'[' Operator
|
|
'0' Literal.Number
|
|
']' Operator
|
|
'.username' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'Filters' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'In the examples above you might have noticed the pipe symbols. Pipe symbols tell' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'the engine that it has to apply a filter on the variable. Here is a small example' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'variable' Name.Variable
|
|
'|' Operator
|
|
'replace' Name.Function
|
|
'(' Operator
|
|
"'foo'" Literal.String.Single
|
|
',' Operator
|
|
' ' Text
|
|
"'bar'" Literal.String.Single
|
|
')' Operator
|
|
'|' Operator
|
|
'escape' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'If you want, you can also put whitespace between the filters.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'This will look for a variable ' Text
|
|
'`variable`' Name.Variable
|
|
', pass it to the filter ' Text
|
|
'`replace`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
'with the arguments ' Text
|
|
'``' Literal.String
|
|
"'foo'" Literal.String
|
|
'``' Literal.String
|
|
' and ' Text
|
|
'``' Literal.String
|
|
"'bar'" Literal.String
|
|
'``' Literal.String
|
|
', and pass the result to the filter' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'`escape`' Name.Variable
|
|
' that automatically XML-escapes the value. The ' Text
|
|
'`e`' Name.Variable
|
|
' filter is an alias for' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'`escape`' Name.Variable
|
|
'. Here is the complete list of supported filters' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'[' Text
|
|
'[' Text
|
|
'list_of_filters]]' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'admonition' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'note' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' Filters have a pretty low priority. If you want to add fitered values' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' you have to put them into parentheses. The same applies if you want to access' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' attributes' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' ..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'correct:\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'(' Operator
|
|
'foo' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
')' Operator
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'(' Operator
|
|
'bar' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'wrong:\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'foo' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'bar' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
' ' Text
|
|
'correct:\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'(' Operator
|
|
'foo' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
')' Operator
|
|
'.attribute' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'wrong:\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'foo' Name.Variable
|
|
'|' Operator
|
|
'filter' Name.Function
|
|
'.attribute' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'Tests' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=====' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'You can use the ' Text
|
|
'`is`' Name.Variable
|
|
' operator to perform tests on a value' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'4' Literal.Number
|
|
'2' Literal.Number
|
|
' ' Text
|
|
'is' Keyword
|
|
' ' Text
|
|
'numeric' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' -> true\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'"foobar"' Literal.String.Double
|
|
' ' Text
|
|
'is' Keyword
|
|
' ' Text
|
|
'numeric' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' -> false\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
"'FOO'" Literal.String.Single
|
|
' ' Text
|
|
'is' Keyword
|
|
' ' Text
|
|
'upper' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' -> true\n\n' Other
|
|
|
|
'These tests are especially useful when used in ' Text
|
|
'`if`' Name.Variable
|
|
' conditions.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'[' Text
|
|
'[' Text
|
|
'list_of_tests]]' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Global Functions' Generic.Heading
|
|
'\n' Text
|
|
|
|
'================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Test functions and filter functions live in their own namespace. Global' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'functions not. They behave like normal objects in the context. Beside the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'functions added by the application or framewhere there are two functions' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'available per default' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'`range`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' Works like the python ' Text
|
|
'`range function`_' Literal.String
|
|
" just that it doesn't support" Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ranges greater than ' Text
|
|
'``' Literal.String
|
|
'1000000' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'`debug`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' Function that outputs the contents of the context.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Loops' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=====' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'To iterate over a sequence, you can use the ' Text
|
|
'`for`' Name.Variable
|
|
' loop. It basically looks like a' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'normal Python ' Text
|
|
'`for`' Name.Variable
|
|
' loop and works pretty much the same' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'Members' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'user' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'loop' Name.Builtin
|
|
'.index' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' / ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'loop' Name.Builtin
|
|
'.length' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' - ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.username' Name.Variable
|
|
'|' Operator
|
|
'escape' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'else' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'<' Punctuation
|
|
'em' Name.Tag
|
|
'>' Punctuation
|
|
'no users found' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'em' Name.Tag
|
|
'>' Punctuation
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'*Important*' Generic.Emph
|
|
' Contrary to Python is the optional ' Text
|
|
'``' Literal.String
|
|
'else' Literal.String
|
|
'``' Literal.String
|
|
' block only' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'executed if there was no iteration because the sequence was empty.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Inside of a ' Text
|
|
'`for`' Name.Variable
|
|
' loop block you can access some special variables' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' Variable | Description |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+======================+========================================+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.index`' Name.Variable
|
|
' | The current iteration of the loop. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.index0`' Name.Variable
|
|
' | The current iteration of the loop, |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' | starting counting by 0. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.revindex`' Name.Variable
|
|
' | The number of iterations from the end |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' | of the loop. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.revindex0`' Name.Variable
|
|
' | The number of iterations from the end |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' | of the loop, starting counting by 0. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.first`' Name.Variable
|
|
' | True if first iteration. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.last`' Name.Variable
|
|
' | True if last iteration. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.even`' Name.Variable
|
|
' | True if current iteration is even. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.odd`' Name.Variable
|
|
' | True if current iteration is odd. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.length`' Name.Variable
|
|
' | Total number of items in the sequence. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'|' Operator
|
|
' ' Text
|
|
'`loop.parent`' Name.Variable
|
|
' | The context of the parent loop. |' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'+----------------------+----------------------------------------+' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
"Loops also support recursion. Let's assume you have a sitemap where each item" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'might have a number of child items. A template for that could look like this' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'Sitemap\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'ul' Name.Tag
|
|
' ' Text
|
|
'id' Name.Attribute
|
|
'=' Operator
|
|
'"sitemap"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'sitemap' Name.Variable
|
|
' ' Text
|
|
'recursive' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'<' Punctuation
|
|
'a' Name.Tag
|
|
' ' Text
|
|
'href' Name.Attribute
|
|
'=' Operator
|
|
'"' Literal.String
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'item' Name.Variable
|
|
'.url' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'item' Name.Variable
|
|
'.title' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'a' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
'.children' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'<' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'loop' Name.Builtin
|
|
'(' Operator
|
|
'item' Name.Variable
|
|
'.children' Name.Variable
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endif' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'What happens here? Basically the first thing that is different to a normal' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'loop is the additional ' Text
|
|
'``' Literal.String
|
|
'recursive' Literal.String
|
|
'``' Literal.String
|
|
' modifier in the ' Text
|
|
'`for`' Name.Variable
|
|
'-loop declaration.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'It tells the template engine that we want recursion. If recursion is enabled' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'the special ' Text
|
|
'`loop`' Name.Variable
|
|
' variable is callable. If you call it with a sequence it will' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'automatically render the loop at that position with the new sequence as argument.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Cycling' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Sometimes you might want to have different text snippets for each row in a list,' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'for example to have alternating row colors. You can easily do this by using the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'``' Literal.String
|
|
'{% cycle %}' Literal.String
|
|
'``' Literal.String
|
|
' tag' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'ul' Name.Tag
|
|
' ' Text
|
|
'id' Name.Attribute
|
|
'=' Operator
|
|
'"messages"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'message' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'messages' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
' ' Text
|
|
'class' Name.Attribute
|
|
'=' Operator
|
|
'"' Literal.String
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'cycle' Keyword
|
|
' ' Text
|
|
"'row1'" Literal.String.Single
|
|
',' Operator
|
|
' ' Text
|
|
"'row2'" Literal.String.Single
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'message' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'ul' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'Each time Jinja encounters a ' Text
|
|
'`cycle`' Name.Variable
|
|
' tag it will cycle through the list' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'of given items and return the next one. If you pass it one item jinja assumes' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'that this item is a sequence from the context and uses this' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'li' Name.Tag
|
|
' ' Text
|
|
'style' Name.Attribute
|
|
'=' Operator
|
|
'"color: ' Literal.String
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'cycle' Keyword
|
|
' ' Text
|
|
'rowcolors' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'"' Literal.String
|
|
'>' Punctuation
|
|
'...' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'li' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'Conditions' Generic.Heading
|
|
'\n' Text
|
|
|
|
'==========' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Jinja supports Python-like ' Text
|
|
'`if`' Name.Variable
|
|
' / ' Text
|
|
'`elif`' Name.Variable
|
|
' / ' Text
|
|
'`else`' Name.Variable
|
|
' constructs' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.active' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' user ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.name' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' is active.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'elif' Keyword
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.deleted' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' user ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.name' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' was deleted some time ago.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'else' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
" i don't know what's wrong with " Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.username' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endif' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'If the user is active the first block is rendered. If not and the user was' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'deleted the second one, in all other cases the third one.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'You can also use comparison operators' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'amount' Name.Variable
|
|
' ' Text
|
|
'<' Operator
|
|
' ' Text
|
|
'0' Literal.Number
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'span' Name.Tag
|
|
' ' Text
|
|
'style' Name.Attribute
|
|
'=' Operator
|
|
'"color: red"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'amount' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'span' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'else' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'span' Name.Tag
|
|
' ' Text
|
|
'style' Name.Attribute
|
|
'=' Operator
|
|
'"color: black"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'amount' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'span' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endif' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'admonition' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'Note' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' Of course you can use ' Text
|
|
'`or`' Name.Variable
|
|
' / ' Text
|
|
'`and`' Name.Variable
|
|
' and parentheses to create more complex' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' conditions, but usually the logic is already handled in the application and' Text
|
|
'\n' Text.Whitespace
|
|
|
|
" you don't have to create such complex constructs in the template code. However" Text
|
|
'\n' Text.Whitespace
|
|
|
|
' in some situations it might be a good thing to have the abilities to create' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' them.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Operators' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=========' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Inside ' Text
|
|
'``' Literal.String
|
|
'{{ variable }}' Literal.String
|
|
'``' Literal.String
|
|
' blocks, ' Text
|
|
'`if`' Name.Variable
|
|
' conditions and many other parts you can' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'can use expressions. In expressions you can use any of the following operators' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' ======= ===================================================================' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'+' Literal.String
|
|
'``' Literal.String
|
|
' add the right operand to the left one.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ 1 + 2 }}' Literal.String
|
|
'``' Literal.String
|
|
' would return ' Text
|
|
'``' Literal.String
|
|
'3' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'-' Literal.String
|
|
'``' Literal.String
|
|
' subtract the right operand from the left one.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ 1 - 1 }}' Literal.String
|
|
'``' Literal.String
|
|
' would return ' Text
|
|
'``' Literal.String
|
|
'0' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'/' Literal.String
|
|
'``' Literal.String
|
|
' divide the left operand by the right one.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ 1 / 2 }}' Literal.String
|
|
'``' Literal.String
|
|
' would return ' Text
|
|
'``' Literal.String
|
|
'0.5' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'*' Literal.String
|
|
'``' Literal.String
|
|
' multiply the left operand with the right one.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ 2 * 2 }}' Literal.String
|
|
'``' Literal.String
|
|
' would return ' Text
|
|
'``' Literal.String
|
|
'4' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'**' Literal.String
|
|
'``' Literal.String
|
|
' raise the left operand to the power of the right' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' operand. ' Text
|
|
'``' Literal.String
|
|
'{{ 2**3 }}' Literal.String
|
|
'``' Literal.String
|
|
' would return ' Text
|
|
'``' Literal.String
|
|
'8' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'in' Literal.String
|
|
'``' Literal.String
|
|
' perform sequence membership test. ' Text
|
|
'``' Literal.String
|
|
'{{ 1 in [1,2,3] }}' Literal.String
|
|
'``' Literal.String
|
|
' would' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' return true.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'is' Literal.String
|
|
'``' Literal.String
|
|
' perform a test on the value. See the section about' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' tests for more information.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'|' Literal.String
|
|
'``' Literal.String
|
|
' apply a filter on the value. See the section about' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' filters for more information.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'and' Literal.String
|
|
'``' Literal.String
|
|
' return true if the left and the right operand is true.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'or' Literal.String
|
|
'``' Literal.String
|
|
' return true if the left or the right operand is true.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'not' Literal.String
|
|
'``' Literal.String
|
|
' negate a statement (see below)' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'``' Literal.String
|
|
'()' Literal.String
|
|
'``' Literal.String
|
|
' call a callable' Text
|
|
':' Text
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ user.get_username() }}' Literal.String
|
|
'``' Literal.String
|
|
'. Inside of the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' parentheses you can use variables' Text
|
|
':' Text
|
|
' ' Text
|
|
'``' Literal.String
|
|
'{{ user.get(username) }}' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ======= ===================================================================' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Note that there is no support for any bit operations or something similar.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text
|
|
|
|
'*' Literal.Number
|
|
' special note regarding ' Text
|
|
'`not`' Name.Variable
|
|
':' Text
|
|
' The ' Text
|
|
'`is`' Name.Variable
|
|
' and ' Text
|
|
'`in`' Name.Variable
|
|
' operators support negation' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' using an infix notation too' Text
|
|
':' Text
|
|
' ' Text
|
|
'``' Literal.String
|
|
'foo is not bar' Literal.String
|
|
'``' Literal.String
|
|
' and ' Text
|
|
'``' Literal.String
|
|
'foo not in bar' Literal.String
|
|
'``' Literal.String
|
|
'\n' Text.Whitespace
|
|
|
|
' instead of ' Text
|
|
'``' Literal.String
|
|
'not foo is bar' Literal.String
|
|
'``' Literal.String
|
|
' and ' Text
|
|
'``' Literal.String
|
|
'not foo in bar' Literal.String
|
|
'``' Literal.String
|
|
'. All other expressions' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' require a prefix notation' Text
|
|
':' Text
|
|
' ' Text
|
|
'``' Literal.String
|
|
'not (foo and bar)' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Boolean Values' Generic.Heading
|
|
'\n' Text
|
|
|
|
'==============' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'In If-Conditions Jinja performs a boolean check. All empty values (eg' Text
|
|
':' Text
|
|
' empty' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'lists ' Text
|
|
'``' Literal.String
|
|
'[]' Literal.String
|
|
'``' Literal.String
|
|
', empty dicts ' Text
|
|
'``' Literal.String
|
|
'{}' Literal.String
|
|
'``' Literal.String
|
|
' etc) evaluate to ' Text
|
|
'`false`' Name.Variable
|
|
'. Numbers that are' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'equal to ' Text
|
|
'`0`' Name.Variable
|
|
'/' Text
|
|
'`0.00`' Name.Variable
|
|
' are considered ' Text
|
|
'`false`' Name.Variable
|
|
' too. The boolean value of other' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'objects depends on the behavior the application developer gave it. Usually' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'items are ' Text
|
|
'`true`' Name.Variable
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Here some examples that should explain it' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'[' Operator
|
|
']' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
" will always be false because it's an empty list\n\n" Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'{' Operator
|
|
'}' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' false too.\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'[' Operator
|
|
"'foo'" Literal.String.Single
|
|
']' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' this is true. Because the list is not empty.\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'"foobar"' Literal.String.Double
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' this is also true because the string is not empty.\n\n' Other
|
|
|
|
'Slicing' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Some objects support slicing operations. For example lists' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'items' Name.Variable
|
|
'[' Operator
|
|
':' Operator
|
|
'5' Literal.Number
|
|
']' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' This will only iterate over the first 5 items of the list\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'items' Name.Variable
|
|
'[' Operator
|
|
'5' Literal.Number
|
|
':' Operator
|
|
'1' Literal.Number
|
|
'0' Literal.Number
|
|
']' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' This will only iterate from item 5 to 10.\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'item' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'items' Name.Variable
|
|
'[' Operator
|
|
':' Operator
|
|
'1' Literal.Number
|
|
'0' Literal.Number
|
|
':' Operator
|
|
'2' Literal.Number
|
|
']' Operator
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' This will only yield items from start to ten and only returing\n' Other
|
|
|
|
' ' Text
|
|
' even items.\n\n' Other
|
|
|
|
'For more informations about slicing have a look at the ' Text
|
|
'`slicing chapter`_' Literal.String
|
|
'\n' Text.Whitespace
|
|
|
|
'in the "Dive into Python" e-book.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Macros' Generic.Heading
|
|
'\n' Text
|
|
|
|
'======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'If you want to use a partial template in more than one place, you might want to' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'create a macro from it' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'macro' Keyword
|
|
' ' Text
|
|
'show_user' Name.Variable
|
|
' ' Text
|
|
'user' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.name' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'div' Name.Tag
|
|
' ' Text
|
|
'class' Name.Attribute
|
|
'=' Operator
|
|
'"test"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'.description' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'div' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endmacro' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
'Now you can use it from everywhere in the code by passing it an item' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n \n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'user' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'show_user' Name.Variable
|
|
'(' Operator
|
|
'user' Name.Variable
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'You can also specify more than one value' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'macro' Keyword
|
|
' ' Text
|
|
'show_dialog' Name.Variable
|
|
' ' Text
|
|
'title' Name.Variable
|
|
',' Operator
|
|
' ' Text
|
|
'text' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'div' Name.Tag
|
|
' ' Text
|
|
'class' Name.Attribute
|
|
'=' Operator
|
|
'"dialog"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'title' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'div' Name.Tag
|
|
' ' Text
|
|
'class' Name.Attribute
|
|
'=' Operator
|
|
'"test"' Literal.String
|
|
'>' Punctuation
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'text' Name.Variable
|
|
'|' Operator
|
|
'e' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'div' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'div' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endmacro' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'show_dialog' Name.Variable
|
|
'(' Operator
|
|
"'Warning'" Literal.String.Single
|
|
',' Operator
|
|
' ' Text
|
|
"'something went wrong i guess'" Literal.String.Single
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
'Inheritance' Generic.Heading
|
|
'\n' Text
|
|
|
|
'===========' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'The most powerful part of Jinja is template inheritance. Template inheritance' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'allows you to build a base "skeleton" template that contains all the common' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'elements of your site and defines ' Text
|
|
'**blocks**' Generic.Strong
|
|
' that child templates can override.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
"Sounds complicated but is very basic. It's easiest to understand it by starting" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'with an example.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Base Template' Generic.Heading
|
|
'\n' Text
|
|
|
|
'-------------' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
"This template, which we'll call " Text
|
|
'``' Literal.String
|
|
'base.html' Literal.String
|
|
'``' Literal.String
|
|
', defines a simple HTML skeleton' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"document that you might use for a simple two-column page. It's the job of" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'"child" templates to fill the empty blocks with content' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n' Comment.Preproc
|
|
|
|
' ' Text
|
|
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'html' Name.Tag
|
|
' ' Text
|
|
'xmlns' Name.Attribute
|
|
'=' Operator
|
|
'"http://www.w3.org/1999/xhtml"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'head' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'link' Name.Tag
|
|
' ' Text
|
|
'rel' Name.Attribute
|
|
'=' Operator
|
|
'"stylesheet"' Literal.String
|
|
' ' Text
|
|
'href' Name.Attribute
|
|
'=' Operator
|
|
'"style.css"' Literal.String
|
|
' ' Text
|
|
'/' Punctuation
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'title' Name.Tag
|
|
'>' Punctuation
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'title' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
' - My Webpage' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'title' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'html_head' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'head' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'body' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'div' Name.Tag
|
|
' ' Text
|
|
'id' Name.Attribute
|
|
'=' Operator
|
|
'"content"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'content' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'div' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'div' Name.Tag
|
|
' ' Text
|
|
'id' Name.Attribute
|
|
'=' Operator
|
|
'"footer"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'footer' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'©' Name.Entity
|
|
' Copyright 2006 by ' Text
|
|
'<' Punctuation
|
|
'a' Name.Tag
|
|
' ' Text
|
|
'href' Name.Attribute
|
|
'=' Operator
|
|
'"http://mydomain.tld"' Literal.String
|
|
'>' Punctuation
|
|
'myself' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'a' Name.Tag
|
|
'>' Punctuation
|
|
'.\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'div' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'body' Name.Tag
|
|
'>' Punctuation
|
|
'\n\n' Text
|
|
|
|
'In this example, the ' Text
|
|
'``' Literal.String
|
|
'{% block %}' Literal.String
|
|
'``' Literal.String
|
|
' tags define four blocks that child templates' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'can fill in. All the ' Text
|
|
'`block`' Name.Variable
|
|
' tag does is to tell the template engine that a' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'child template may override those portions of the template.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Child Template' Generic.Heading
|
|
'\n' Text
|
|
|
|
'--------------' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'A child template might look like this' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'html+jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'extends' Keyword
|
|
' ' Text
|
|
'"base.html"' Literal.String.Double
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'title' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'Index' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'html_head' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'style' Name.Tag
|
|
' ' Text
|
|
'type' Name.Attribute
|
|
'=' Operator
|
|
'"text/css"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
' ' Text.Whitespace
|
|
'.' Punctuation
|
|
'important' Name.Class
|
|
' ' Text.Whitespace
|
|
'{' Punctuation
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
' ' Text.Whitespace
|
|
'color' Keyword
|
|
':' Punctuation
|
|
' ' Text.Whitespace
|
|
'#336699' Literal.Number.Hex
|
|
';' Punctuation
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
' ' Text.Whitespace
|
|
'}' Punctuation
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
' ' Text.Whitespace
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'style' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'block' Keyword
|
|
' ' Text
|
|
'content' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'Index' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'h1' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'p' Name.Tag
|
|
' ' Text
|
|
'class' Name.Attribute
|
|
'=' Operator
|
|
'"important"' Literal.String
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' Welcome on my awsome homepage.\n' Text
|
|
|
|
' ' Text
|
|
' ' Text
|
|
'<' Punctuation
|
|
'/' Punctuation
|
|
'p' Name.Tag
|
|
'>' Punctuation
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endblock' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Text
|
|
|
|
'The ' Text
|
|
'``' Literal.String
|
|
'{% extends %}' Literal.String
|
|
'``' Literal.String
|
|
' tag is the key here. It tells the template engine that' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'this template "extends" another template. When the template system evaluates' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'this template, first it locates the parent.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'The filename of the template depends on the template loader. For example the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'``' Literal.String
|
|
'FileSystemLoader' Literal.String
|
|
'``' Literal.String
|
|
' allows you to access other templates by giving the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'filename. You can access templates in subdirectories with an slash' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'extends' Keyword
|
|
' ' Text
|
|
'"layout/default.html"' Literal.String.Double
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'But this behavior can depend on the application using Jinja.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
"Note that since the child template didn't define the " Text
|
|
'``' Literal.String
|
|
'footer' Literal.String
|
|
'``' Literal.String
|
|
' block, the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'value from the parent template is used instead.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'admonition' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'Note' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
" You can't define multiple " Text
|
|
'``' Literal.String
|
|
'{% block %}' Literal.String
|
|
'``' Literal.String
|
|
' tags with the same name in the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' same template. This limitation exists because a block tag works in "both"' Text
|
|
'\n' Text.Whitespace
|
|
|
|
" directions. That is, a block tag doesn't just provide a hole to fill - it" Text
|
|
'\n' Text.Whitespace
|
|
|
|
' also defines the content that fills the hole in the ' Text
|
|
'*parent*' Generic.Emph
|
|
'. If there were' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' two similarly-named ' Text
|
|
'``' Literal.String
|
|
'{% block %}' Literal.String
|
|
'``' Literal.String
|
|
" tags in a template, that template's" Text
|
|
'\n' Text.Whitespace
|
|
|
|
" parent wouldn't know which one of the blocks' content to use." Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Template Inclusion' Generic.Heading
|
|
'\n' Text
|
|
|
|
'==================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'You can load another template at a given position using ' Text
|
|
'``' Literal.String
|
|
'{% include %}' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"Usually it's a better idea to use inheritance but if you for example want to" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'load macros, ' Text
|
|
'`include`' Name.Variable
|
|
' works better than ' Text
|
|
'`extends`' Name.Variable
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'include' Keyword
|
|
' ' Text
|
|
'"myhelpers.html"' Literal.String.Double
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'my_helper' Name.Variable
|
|
'(' Operator
|
|
'"foo"' Literal.String.Double
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'If you define a macro called ' Text
|
|
'``' Literal.String
|
|
'my_helper' Literal.String
|
|
'``' Literal.String
|
|
' in ' Text
|
|
'``' Literal.String
|
|
'myhelpers.html' Literal.String
|
|
'``' Literal.String
|
|
', you can now' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'use it from the template as shown above.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Filtering Blocks' Generic.Heading
|
|
'\n' Text
|
|
|
|
'================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Sometimes it could be a good idea to filter a complete block of text. For' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'example, if you want to escape some html code' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'filter' Keyword
|
|
' ' Text
|
|
'escape' Name.Function
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' <html>\n' Other
|
|
|
|
' ' Text
|
|
' <code>goes here</code>\n' Other
|
|
|
|
' ' Text
|
|
' </html>\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfilter' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'Of course you can chain filters too' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'filter' Keyword
|
|
' ' Text
|
|
'lower' Name.Function
|
|
'|' Operator
|
|
'escape' Name.Function
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' <B>SOME TEXT</B>\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfilter' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'returns ' Text
|
|
'``' Literal.String
|
|
'"<b>some text</b>"' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Defining Variables' Generic.Heading
|
|
'\n' Text
|
|
|
|
'==================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'You can also define variables in the namespace using the ' Text
|
|
'``' Literal.String
|
|
'{% set %}' Literal.String
|
|
'``' Literal.String
|
|
' tag' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'set' Keyword
|
|
' ' Text
|
|
'foo' Name.Variable
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
"'foobar'" Literal.String.Single
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'foo' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'This should ouput ' Text
|
|
'``' Literal.String
|
|
'foobar' Literal.String
|
|
'``' Literal.String
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Scopes' Generic.Heading
|
|
'\n' Text
|
|
|
|
'======' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Jinja has multiple scopes. A scope is something like a new transparent foil on' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'a stack of foils. You can only write to the outermost foil but read all of them' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'since you can look through them. If you remove the top foil all data on that' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'foil disappears. Some tags in Jinja add a new layer to the stack. Currently' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'these are ' Text
|
|
'`block`' Name.Variable
|
|
', ' Text
|
|
'`for`' Name.Variable
|
|
', ' Text
|
|
'`macro`' Name.Variable
|
|
' and ' Text
|
|
'`filter`' Name.Variable
|
|
'. This means that variables and' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'other elements defined inside a macro, loop or some of the other tags listed' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'above will be only available in that block. Here an example' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'macro' Keyword
|
|
' ' Text
|
|
'angryhello' Name.Variable
|
|
' ' Text
|
|
'name' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'set' Keyword
|
|
' ' Text
|
|
'angryname' Name.Variable
|
|
' ' Text
|
|
'=' Operator
|
|
' ' Text
|
|
'name' Name.Variable
|
|
'|' Operator
|
|
'upper' Name.Function
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' Hello ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'name' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'. Hello ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'name' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'!\n' Other
|
|
|
|
' ' Text
|
|
' HELLO ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'angryname' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'!!!!!!111\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endmacro' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'The variable ' Text
|
|
'``' Literal.String
|
|
'angryname' Literal.String
|
|
'``' Literal.String
|
|
' just exists inside the macro, not outside it.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Defined macros appear on the context as variables. Because of this, they are' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'affected by the scoping too. A macro defined inside of a macro is just available' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"in those two macros (the macro itself and the macro it's defined in). For " Text
|
|
'`set`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
'and ' Text
|
|
'`macro`' Name.Variable
|
|
' two additional rules exist' Text
|
|
':' Text
|
|
' If a macro is defined in an extended' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'template but outside of a visible block (thus outside of any block) will be' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'available in all blocks below. This allows you to use ' Text
|
|
'`include`' Name.Variable
|
|
' statements to' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'load often used macros at once.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Undefined Variables' Generic.Heading
|
|
'\n' Text
|
|
|
|
'===================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'If you have already worked with python you probably know about the fact that' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'undefined variables raise an exception. This is different in Jinja. There is a' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'special value called ' Text
|
|
'`undefined`' Name.Variable
|
|
' that represents values that do not exist.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'This special variable works complete different from any variables you maybe' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'know. If you print it using ' Text
|
|
'``' Literal.String
|
|
'{{ variable }}' Literal.String
|
|
'``' Literal.String
|
|
" it will not appear because it's" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'literally empty. If you try to iterate over it, it will work. But no items' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'are returned. Comparing this value to any other value results in ' Text
|
|
'`false`' Name.Variable
|
|
'.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'Even if you compare it to itself' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
' ' Text
|
|
'==' Operator
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' will return false. Not even undefined is undefined :)\n' Other
|
|
|
|
' ' Text
|
|
' Use `is defined` / `is not defined`:\n\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
' ' Text
|
|
'is' Keyword
|
|
' ' Text
|
|
'not' Keyword
|
|
' ' Text
|
|
'defined' Name.Function
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' will return true.\n\n' Other
|
|
|
|
'There are also some additional rules regarding this special value. Any' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'mathematical operators (' Text
|
|
'``' Literal.String
|
|
'+' Literal.String
|
|
'``' Literal.String
|
|
', ' Text
|
|
'``' Literal.String
|
|
'-' Literal.String
|
|
'``' Literal.String
|
|
', ' Text
|
|
'``' Literal.String
|
|
'*' Literal.String
|
|
'``' Literal.String
|
|
', ' Text
|
|
'``' Literal.String
|
|
'/' Literal.String
|
|
'``' Literal.String
|
|
') return the operand' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'as result' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
' ' Text
|
|
'+' Operator
|
|
' ' Text
|
|
'"foo"' Literal.String.Double
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' returns "foo"\n\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
' ' Text
|
|
'-' Operator
|
|
' ' Text
|
|
'4' Literal.Number
|
|
'2' Literal.Number
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' returns 42. Note: not -42!\n\n' Other
|
|
|
|
'In any expression ' Text
|
|
'`undefined`' Name.Variable
|
|
' evaluates to ' Text
|
|
'`false`' Name.Variable
|
|
'. It has no length, all' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'attribute calls return undefined, calling too' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'undefined' Name.Variable
|
|
'.attribute' Name.Variable
|
|
'(' Operator
|
|
')' Operator
|
|
'.attribute_too' Name.Variable
|
|
'[' Operator
|
|
'4' Literal.Number
|
|
'2' Literal.Number
|
|
']' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' still returns `undefined`.\n\n' Other
|
|
|
|
'Escaping' Generic.Heading
|
|
'\n' Text
|
|
|
|
'========' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Sometimes you might want to add Jinja syntax elements into the template' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'without executing them. In that case you have quite a few possibilities.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'For small parts this might be a good way' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'"{{ foo }} is variable syntax and {% foo %} is block syntax"' Literal.String.Double
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'When you have multiple elements you can use the ' Text
|
|
'``' Literal.String
|
|
'raw' Literal.String
|
|
'``' Literal.String
|
|
' block' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'raw' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Text
|
|
|
|
' ' Text
|
|
' Filtering blocks works like this in Jinja:\n' Text
|
|
|
|
' ' Text
|
|
' {% filter escape %}\n' Text
|
|
|
|
' ' Text
|
|
' <html>\n' Text
|
|
|
|
' ' Text
|
|
' <code>goes here</code>\n' Text
|
|
|
|
' ' Text
|
|
' </html>\n' Text
|
|
|
|
' ' Text
|
|
' {% endfilter %}\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endraw' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'Reserved Keywords' Generic.Heading
|
|
'\n' Text
|
|
|
|
'=================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Jinja has some keywords you cannot use a variable names. This limitation' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"exists to make look coherent. Syntax highlighters won't mess things up and" Text
|
|
'\n' Text.Whitespace
|
|
|
|
"you will don't have unexpected output." Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'The following keywords exist and cannot be used as identifiers' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'`and`' Name.Variable
|
|
', ' Text
|
|
'`block`' Name.Variable
|
|
', ' Text
|
|
'`cycle`' Name.Variable
|
|
', ' Text
|
|
'`elif`' Name.Variable
|
|
', ' Text
|
|
'`else`' Name.Variable
|
|
', ' Text
|
|
'`endblock`' Name.Variable
|
|
', ' Text
|
|
'`endfilter`' Name.Variable
|
|
',' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'`endfor`' Name.Variable
|
|
', ' Text
|
|
'`endif`' Name.Variable
|
|
', ' Text
|
|
'`endmacro`' Name.Variable
|
|
', ' Text
|
|
'`endraw`' Name.Variable
|
|
', ' Text
|
|
'`endtrans`' Name.Variable
|
|
', ' Text
|
|
'`extends`' Name.Variable
|
|
', ' Text
|
|
'`filter`' Name.Variable
|
|
',' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'`for`' Name.Variable
|
|
', ' Text
|
|
'`if`' Name.Variable
|
|
', ' Text
|
|
'`in`' Name.Variable
|
|
', ' Text
|
|
'`include`' Name.Variable
|
|
', ' Text
|
|
'`is`' Name.Variable
|
|
', ' Text
|
|
'`macro`' Name.Variable
|
|
', ' Text
|
|
'`not`' Name.Variable
|
|
', ' Text
|
|
'`or`' Name.Variable
|
|
', ' Text
|
|
'`pluralize`' Name.Variable
|
|
',' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'`raw`' Name.Variable
|
|
', ' Text
|
|
'`recursive`' Name.Variable
|
|
', ' Text
|
|
'`set`' Name.Variable
|
|
', ' Text
|
|
'`trans`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'If you want to use such a name you have to prefix or suffix it or use' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'alternative names' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'for' Keyword
|
|
' ' Text
|
|
'macro_' Name.Variable
|
|
' ' Text
|
|
'in' Keyword
|
|
' ' Text
|
|
'macros' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'macro_' Name.Variable
|
|
'(' Operator
|
|
"'foo'" Literal.String.Single
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endfor' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'If future Jinja releases add new keywords those will be "light" keywords which' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"means that they won't raise an error for several releases but yield warnings" Text
|
|
'\n' Text.Whitespace
|
|
|
|
"on the application side. But it's very unlikely that new keywords will be" Text
|
|
'\n' Text.Whitespace
|
|
|
|
'added.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Internationalization' Generic.Heading
|
|
'\n' Text
|
|
|
|
'====================' Generic.Heading
|
|
'\n' Text
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'If the application is configured for i18n, you can define translatable blocks' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'for translators using the ' Text
|
|
'`trans`' Name.Variable
|
|
' tag or the special underscore function' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'trans' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' this is a translatable block\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endtrans' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'trans' Keyword
|
|
' ' Text
|
|
'"This is a translatable string"' Literal.String.Double
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
' ' Text
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'_' Keyword.Pseudo
|
|
'(' Operator
|
|
'"This is a translatable string"' Literal.String.Double
|
|
')' Operator
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'The latter one is useful if you want translatable arguments for filters etc.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'If you want to have plural forms too, use the ' Text
|
|
'`pluralize`' Name.Variable
|
|
' block' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'trans' Keyword
|
|
' ' Text
|
|
'users' Name.Variable
|
|
'=' Operator
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' One user found.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'pluralize' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' users found.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endtrans' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'trans' Keyword
|
|
' ' Text
|
|
'first' Name.Variable
|
|
'=' Operator
|
|
'(' Operator
|
|
'users' Name.Variable
|
|
'|' Operator
|
|
'first' Name.Function
|
|
')' Operator
|
|
'.username' Name.Variable
|
|
'|' Operator
|
|
'escape' Name.Function
|
|
',' Operator
|
|
' ' Text
|
|
'user' Name.Variable
|
|
'=' Operator
|
|
'users' Name.Variable
|
|
'|' Operator
|
|
'length' Name.Function
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' one user ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'first' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' found.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'pluralize' Keyword
|
|
' ' Text
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'users' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' users found, the first one is called ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'first' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
'.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endtrans' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'If you have multiple arguments, the first one is assumed to be the indicator (the' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'number that is used to determine the correct singular or plural form. If you' Text
|
|
'\n' Text.Whitespace
|
|
|
|
"don't have the indicator variable on position 1 you have to tell the " Text
|
|
'`pluralize`' Name.Variable
|
|
'\n' Text.Whitespace
|
|
|
|
'tag the correct variable name.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'Inside translatable blocks you cannot use blocks or expressions (however you can' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'still use the ' Text
|
|
'``' Literal.String
|
|
'raw' Literal.String
|
|
'``' Literal.String
|
|
' block which will work as expected). The variable' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'print syntax (' Text
|
|
'``' Literal.String
|
|
'{{ variablename }}' Literal.String
|
|
'``' Literal.String
|
|
') is the only way to insert the variables' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'defined in the ' Text
|
|
'``' Literal.String
|
|
'trans' Literal.String
|
|
'``' Literal.String
|
|
' header. Filters must be applied in the header.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'admonition' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'note' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' Please make sure that you always use pluralize blocks where required.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' Many languages have more complex plural forms than the English language.' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' ' Text
|
|
'\n' Text.Whitespace
|
|
|
|
' Never try to workaround that issue by using something like this' Text
|
|
':' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'\n' Text.Whitespace
|
|
|
|
' ..' Punctuation
|
|
' ' Text
|
|
'sourcecode' Operator.Word
|
|
'::' Punctuation
|
|
' ' Text
|
|
'jinja' Keyword
|
|
'\n\n' Text
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'if' Keyword
|
|
' ' Text
|
|
'count' Name.Variable
|
|
' ' Text
|
|
'!=' Operator
|
|
' ' Text
|
|
'1' Literal.Number
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' ' Other
|
|
'{{' Comment.Preproc
|
|
' ' Text
|
|
'count' Name.Variable
|
|
' ' Text
|
|
'}}' Comment.Preproc
|
|
' users found.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'else' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n' Other
|
|
|
|
' ' Text
|
|
' one user found.\n' Other
|
|
|
|
' ' Text
|
|
'{%' Comment.Preproc
|
|
' ' Text
|
|
'endif' Keyword
|
|
' ' Text
|
|
'%}' Comment.Preproc
|
|
'\n\n' Other
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'_slicing chapter:' Name.Tag
|
|
' http' Text
|
|
':' Text
|
|
'//diveintopython.org/native_data_types/lists.html#odbchelper.list.slice' Text
|
|
'\n' Text.Whitespace
|
|
|
|
'..' Punctuation
|
|
' ' Text
|
|
'_range function:' Name.Tag
|
|
' http' Text
|
|
':' Text
|
|
'//docs.python.org/tut/node6.html#SECTION006300000000000000000' Text
|
|
'\n' Text.Whitespace
|