Files
tree-sitter-django/test/corpus/template_variable.txt
T
2026-09-14 21:40:26 -05:00

611 lines
8.3 KiB
Plaintext

==================
Template Variable Integer
==================
{{ 42 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Negative Float
==================
{{ -3.14 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Scientific Notation
==================
{{ 1.5e10 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Double Quoted String
==================
{{ "hello world" }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(string)))))
(content))
==================
Template Variable Single Quoted String With Escape
==================
{{ 'it\'s ok' }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(string)))))
(content))
==================
Template Variable Identifier
==================
{{ name }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))))
(content))
==================
Template Variable Attribute Access
==================
{{ user.profile.email }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)
(attribute)))))
(content))
==================
Template Variable With Single Filter
==================
{{ name|upper }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter))))
(content))
==================
Template Variable With Filter Chain
==================
{{ name|lower|title }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter)
(filter))))
(content))
==================
Template Variable With Filter Argument
==================
{{ price|add:"5" }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter
argument: (value
(literal
(string)))))))
(content))
==================
Template Variable Number With Filter Argument
==================
{{ 3.14|floatformat:2 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))
(filter_expression
(filter
argument: (value
(literal
(number)))))))
(content))
==================
Template Variable Literal Adjacent To Name
:error
==================
{{ 1x }}
---
==================
Template Variable With Escaped String
==================
{{ "a\nb\"c" }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(string)))))
(content))
==================
Template Variable Signed Number
==================
{{ +1.5 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Underscore Separated Number
==================
{{ 1_000 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Attribute Beginning With Underscore
:error
==================
{{ user._private }}
---
==================
Template Variable Translated String
==================
{{ _("Hello") }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(translated_string
(string))))))
(content))
==================
Template Variable Translated String With Filter
==================
{{ _('Hello')|upper }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(translated_string
(string))))
(filter_expression
(filter))))
(content))
==================
Template Variable Translated String With Spaces
:error
==================
{{ _( "Hello" ) }}
---
==================
Template Variable Spanning Lines
==================
{{ value
|floatformat:2 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter
argument: (value
(literal
(number)))))))
(content))
==================
Template Variable With Spaced Filter
==================
{{ value | upper }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter))))
(content))
==================
Template Variable True
==================
{{ True }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(boolean)))))
(content))
==================
Template Variable False
==================
{{ False }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(boolean)))))
(content))
==================
Template Variable None
==================
{{ None }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(none)))))
(content))
==================
Template Variable Boolean As Filter Argument
==================
{{ value|default:True }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))
(filter_expression
(filter
argument: (value
(literal
(boolean)))))))
(content))
==================
Template Variable Name Beginning With A Literal
==================
{{ Truest }}
---
(template
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier)))))
(content))
==================
Template Variable Attribute Of A Literal
:error
==================
{{ None.x }}
---
==================
Template Variable Trailing Dot With An Exponent
==================
{{ 1.e5 }}
---
(template
(content)
(template_variable
(filtered_value
(value
(literal
(number)))))
(content))
==================
Template Variable Trailing Dot
:error
==================
{{ 1. }}
---
==================
Template Variable Signed Trailing Dot
:error
==================
{{ -1. }}
---
==================
Braces That Open Nothing Are Text
==================
{% if x %}Hello {} world{% endif %}
---
(template
(content)
(if_group
(if_block
(if_tag
(predicate
(filtered_value
(value
(variable_attribute
(identifier))))))
(template
(content)))
(endif_tag))
(content))
==================
A Brace Before A Tag Is Text
==================
Hello {{% if x %}a{% endif %}
---
(template
(content)
(if_group
(if_block
(if_tag
(predicate
(filtered_value
(value
(variable_attribute
(identifier))))))
(template
(content)))
(endif_tag))
(content))
==================
A Brace Before A Comment Is Text
==================
a{{# c #}
---
(template
(content)
(template_comment)
(content))
==================
A Brace At The End Is Text
==================
a{
---
(template
(content))
==================
A Brace Before The End Tag Of A Group Is Text
==================
{% if x %}Hello {{% endif %}
---
(template
(content)
(if_group
(if_block
(if_tag
(predicate
(filtered_value
(value
(variable_attribute
(identifier))))))
(template
(content)))
(endif_tag))
(content))
==================
Three Braces Open A Variable
:error
==================
a{{{ x }}
---