patch 9.1.1188: runtime(tera): tera support can be improved
Problem: runtime(tera): tera support can be improved
Solution: update tera filetype plugin, include a tera syntax script
include tera syntax tests, update the filetype test,
update makemenu and synmenu vim scripts
(MuntasirSZN)
closes: #16830
Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/syntax/tera.vim b/runtime/syntax/tera.vim
new file mode 100644
index 0000000..922b9c9
--- /dev/null
+++ b/runtime/syntax/tera.vim
@@ -0,0 +1,96 @@
+" Vim syntax file
+" Language: Tera
+" Maintainer: Muntasir Mahmud <muntasir.joypurhat@gmail.com>
+" Last Change: 2025 Mar 09
+
+if exists("b:current_syntax")
+ finish
+endif
+
+" Detect the underlying language based on filename pattern
+" For files like file.html.tera, we want to load html syntax
+let s:filename = expand("%:t")
+let s:dotpos = strridx(s:filename, '.', strridx(s:filename, '.tera') - 1)
+let s:underlying_filetype = ""
+
+if s:dotpos != -1
+ let s:underlying_ext = s:filename[s:dotpos+1:strridx(s:filename, '.tera')-1]
+ if s:underlying_ext != "" && s:underlying_ext != "tera"
+ let s:underlying_filetype = s:underlying_ext
+ endif
+endif
+
+" Load the underlying language syntax if detected
+if s:underlying_filetype != ""
+ execute "runtime! syntax/" . s:underlying_filetype . ".vim"
+ unlet! b:current_syntax
+else
+ " Default to HTML if no specific language detected
+ runtime! syntax/html.vim
+ unlet! b:current_syntax
+endif
+
+" Tera comment blocks: {# comment #}
+syn region teraCommentBlock start="{#" end="#}" contains=@Spell containedin=cssDefinition,cssStyle,htmlHead,htmlTitle
+
+" Tera statements: {% if condition %}
+syn region teraStatement start="{%" end="%}" contains=teraKeyword,teraString,teraNumber,teraFunction,teraBoolean,teraFilter,teraOperator containedin=cssDefinition,cssStyle,htmlHead,htmlTitle
+
+" Tera expressions: {{ variable }}
+syn region teraExpression start="{{" end="}}" contains=teraString,teraNumber,teraFunction,teraBoolean,teraFilter,teraOperator,teraIdentifier containedin=cssDefinition,cssStyle,htmlHead,htmlTitle
+
+" Special handling for raw blocks - content inside shouldn't be processed
+syn region teraRawBlock start="{% raw %}" end="{% endraw %}" contains=TOP,teraCommentBlock,teraStatement,teraExpression
+
+" Control structure keywords
+syn keyword teraKeyword contained if else elif endif for endfor in macro endmacro
+syn keyword teraKeyword contained block endblock extends include import set endset
+syn keyword teraKeyword contained break continue filter endfilter raw endraw with endwith
+
+" Identifiers - define before operators for correct priority
+syn match teraIdentifier contained "\<\w\+\>"
+
+" Operators used in expressions and statements
+syn match teraOperator contained "==\|!=\|>=\|<=\|>\|<\|+\|-\|*\|/"
+syn match teraOperator contained "{\@<!%}\@!" " Match % but not when part of {% or %}
+syn keyword teraOperator contained and or not is as
+
+" Functions and filters
+syn match teraFunction contained "\<\w\+\ze("
+syn match teraFilter contained "|\_s*\w\+"
+
+" String literals - both single and double quoted
+syn region teraString contained start=+"+ skip=+\\"+ end=+"+ contains=@Spell
+syn region teraString contained start=+'+ skip=+\\'+ end=+'+ contains=@Spell
+
+" Numeric literals - both integer and float
+syn match teraNumber contained "\<\d\+\>"
+syn match teraNumber contained "\<\d\+\.\d\+\>"
+
+" Boolean values
+syn keyword teraBoolean contained true false
+
+" Highlighting links
+hi def link teraCommentBlock Comment
+hi def link teraKeyword Statement
+hi def link teraOperator Operator
+hi def link teraFunction Function
+hi def link teraIdentifier Identifier
+hi def link teraString String
+hi def link teraNumber Number
+hi def link teraBoolean Boolean
+hi def link teraFilter PreProc
+
+" Special highlighting for blocks and expressions
+hi def link teraStatement PreProc
+hi def link teraExpression PreProc
+
+" Clean up script-local variables
+unlet s:filename
+unlet s:dotpos
+if exists("s:underlying_ext")
+ unlet s:underlying_ext
+endif
+unlet s:underlying_filetype
+
+let b:current_syntax = "tera"
diff --git a/runtime/syntax/testdir/dumps/tera_00.dump b/runtime/syntax/testdir/dumps/tera_00.dump
new file mode 100644
index 0000000..5c15b4c
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_00.dump
@@ -0,0 +1,20 @@
+><+0#0000e05#ffffff0|!|D|O|C|T|Y|P|E| |h|t|m|l|>| +0#0000000&@59
+|<+0#00e0e07&|h+0#af5f00255&|t|m|l| +0#00e0e07&|l+0#00e0003&|a|n|g|=+0#00e0e07&|"+0#e000002&|e|n|"|>+0#00e0e07&| +0#0000000&@58
+|<+0#00e0e07&|h+0#af5f00255&|e|a|d|>+0#00e0e07&| +0#0000000&@68
+| +0#e000e06&@3|<+0#00e0e07&|m+0#af5f00255&|e|t|a| +0#00e0e07&|c+0#00e0003&|h|a|r|s|e|t|=+0#00e0e07&|"+0#e000002&|U|T|F|-|8|"|>+0#00e0e07&| +0#0000000&@48
+| +0#e000e06&@3|<+0#00e0e07&|m+0#af5f00255&|e|t|a| +0#00e0e07&|n+0#00e0003&|a|m|e|=+0#00e0e07&|"+0#e000002&|v|i|e|w|p|o|r|t|"| +0#00e0e07&|c+0#00e0003&|o|n|t|e|n|t|=+0#00e0e07&|"+0#e000002&|w|i|d|t|h|=|d|e|v|i|c|e|-|w|i|d|t|h|,| |i|n|i|t|i|a|l|-|s|c|a|l|e|=|1|.|0|"|>+0#00e0e07&| +0#0000000&
+| +0#e000e06&@3|<+0#00e0e07&|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&|{+0#e000e06&@1| |p+0#00e0e07&|a|g|e|_|t|i|t|l|e| +0#e000e06&||| |d|e|f|a|u|l|t|(|v+0#00e0e07&|a|l|u|e|=+0#e000e06&|"+0#e000002&|T|e|r|a| |T|e|s|t|"|)+0#e000e06&| |}@1|<+0#00e0e07&|/|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&| +0#0000000&@10
+| +0#e000e06&@3|{|%| |i+0#af5f00255&|f| +0#e000e06&|i|n|c|l|u|d|e|_|s|t|y|l|e|s| |%|}| +0#0000000&@47
+| +0#e000e06&@3|<+0#00e0e07&|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&| +0#0000000&@63
+@8|b+0#af5f00255&|o|d|y| +0#0000000&|{+0#00e0e07&| +0#0000000&@60
+@12|f+0#00e0003&|o|n|t|-|f|a|m|i|l|y|:+0#0000000&| |{+0#e000e06&@1| |f+0#00e0e07&|o|n|t|_|f|a|m|i|l|y| +0#e000e06&||| |d|e|f|a|u|l|t|(|v+0#00e0e07&|a|l|u|e|=+0#e000e06&|"+0#e000002&|s|a|n|s|-|s|e|r|i|f|"|)+0#e000e06&| |}@1|;+0#0000000&| @1
+@12|c+0#00e0003&|o|l|o|r|:+0#0000000&| |#+0#e000002&|3@2|;+0#0000000&| @50
+@12|l+0#00e0003&|i|n|e|-|h|e|i|g|h|t|:+0#0000000&| |1+0#e000002&|.|6|;+0#0000000&| @45
+@8|}+0#00e0e07&| +0#0000000&@65
+@8|.+0#00e0e07&|c|o|n|t|a|i|n|e|r| +0#0000000&|{+0#00e0e07&| +0#0000000&@54
+@12|w+0#00e0003&|i|d|t|h|:+0#0000000&| |8+0#e000002&|0|%|;+0#0000000&| @51
+@12|m+0#00e0003&|a|r|g|i|n|:+0#0000000&| |0+0#e000002&| +0#0000000&|a+0#e000002&|u|t|o|;+0#0000000&| @47
+@8|}+0#00e0e07&| +0#0000000&@65
+@8|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|d|a|r|k|_|m|o|d|e| |%|}| +0#0000000&@48
+@8|b+0#af5f00255&|o|d|y| +0#0000000&|{+0#00e0e07&| +0#0000000&@60
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/tera_01.dump b/runtime/syntax/testdir/dumps/tera_01.dump
new file mode 100644
index 0000000..67d4a51
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_01.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@7|.+0#00e0e07&|c|o|n|t|a|i|n|e|r| +0#0000000&|{+0#00e0e07&| +0#0000000&@54
+@12|w+0#00e0003&|i|d|t|h|:+0#0000000&| |8+0#e000002&|0|%|;+0#0000000&| @51
+@12|m+0#00e0003&|a|r|g|i|n|:+0#0000000&| |0+0#e000002&| +0#0000000&|a+0#e000002&|u|t|o|;+0#0000000&| @47
+@8|}+0#00e0e07&| +0#0000000&@65
+@8|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|d|a|r|k|_|m|o|d|e| |%|}| +0#0000000&@48
+@8>b+0#af5f00255&|o|d|y| +0#0000000&|{+0#00e0e07&| +0#0000000&@60
+@12|b+0#00e0003&|a|c|k|g|r|o|u|n|d|-|c|o|l|o|r|:+0#0000000&| |#+0#e000002&|2@2|;+0#0000000&| @39
+@12|c+0#00e0003&|o|l|o|r|:+0#0000000&| |#+0#e000002&|e@2|;+0#0000000&| @50
+@8|}+0#00e0e07&| +0#0000000&@65
+@8|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@55
+@4|<+0#00e0e07&|/|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&| +0#0000000&@62
+| +0#e000e06&@3|{|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@59
+|<+0#00e0e07&|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&| +0#0000000&@67
+|<+0#00e0e07&|b+0#af5f00255&|o|d|y|>+0#00e0e07&| +0#0000000&@68
+@4|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|c|o|n|t|a|i|n|e|r|"|>+0#00e0e07&| +0#0000000&@47
+@8|{+0#0000e05&|#| |H|e|a|d|e|r| |S|e|c|t|i|o|n| |w|i|t|h| |v|a|r|i|a|b|l|e| |i|n|t|e|r|p|o|l|a|t|i|o|n| |#|}| +0#0000000&@18
+@8|<+0#00e0e07&|h+0#af5f00255&|e|a|d|e|r|>+0#00e0e07&| +0#0000000&@58
+@12|<+0#00e0e07&|h+0#af5f00255&|1|>+0#00e0e07&|{+0#e000e06&@1| |h|e|a|d|e|r|_|t|e|x|t| ||| |u|p@1|e|r| |}@1|<+0#00e0e07&|/|h+0#af5f00255&|1|>+0#00e0e07&| +0#0000000&@28
+@12|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|s|u|b|h|e|a|d|e|r| |%|}| +0#0000000&@44
+@57|1|9|,|9| @10|8|%|
diff --git a/runtime/syntax/testdir/dumps/tera_02.dump b/runtime/syntax/testdir/dumps/tera_02.dump
new file mode 100644
index 0000000..aab7f08
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_02.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@11|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|s|u|b|h|e|a|d|e|r| |%|}| +0#0000000&@44
+@16|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|{+0#e000e06&@1| |s|u|b|h|e|a|d|e|r| |}@1|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@34
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@51
+@8|<+0#00e0e07&|/|h+0#af5f00255&|e|a|d|e|r|>+0#00e0e07&| +0#0000000&@57
+@75
+@8>{+0#0000e05&|#| |N|a|v|i|g|a|t|i|o|n| |e|x|a|m|p|l|e| |w|i|t|h| |f|o|r| |l|o@1|p| |#|}| +0#0000000&@28
+@8|<+0#00e0e07&|n+0#af5f00255&|a|v|>+0#00e0e07&| +0#0000000&@61
+@12|<+0#00e0e07&|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@58
+@16|{+0#e000e06&|%| |f+0#af5f00255&|o|r| +0#e000e06&|i|t|e|m| |i+0#af5f00255&|n| +0#e000e06&|n|a|v|i|g|a|t|i|o|n| |%|}| +0#0000000&@30
+@20|<+0#00e0e07&|l+0#af5f00255&|i| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|{@1| |l|o@1|p|.|i|n|d|e|x|0| |=@1| |c|u|r@1|e|n|t|_|p|a|g|e| |?| |'|a|c|t|i|v|e|'| |:|
+|'@1| |}@1|"|>+0#00e0e07&| +0#0000000&@67
+@24|<+0#00e0e07&|a+0#af5f00255&| +0#00e0e07&|h+0#00e0003&|r|e|f|=+0#00e0e07&|"+0#e000002&|{@1| |i|t|e|m|.|u|r|l| |}@1|"|>+0#00e0e07&|{+8#e000e06&@1| |i|t|e|m|.|t|i|t|l|e| |}@1|<+0#00e0e07&|/|a+0#af5f00255&|>+0#00e0e07&| +0#0000000&@5
+@20|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&| +0#0000000&@49
+@16|{+0#e000e06&|%| |e+0#af5f00255&|n|d|f|o|r| +0#e000e06&|%|}| +0#0000000&@46
+@12|<+0#00e0e07&|/|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@57
+@8|<+0#00e0e07&|/|n+0#af5f00255&|a|v|>+0#00e0e07&| +0#0000000&@60
+@75
+@8|{+0#0000e05&|#| |M|a|i|n| |c|o|n|t|e|n|t| |s|e|c|t|i|o|n| |w|i|t|h| |v|a|r|i|o|u|s| |t|e|m|p|l|a|t|e| |f|e|a|t|u|r|e|s| |#|}| +0#0000000&@9
+@8|<+0#00e0e07&|m+0#af5f00255&|a|i|n|>+0#00e0e07&| +0#0000000&@60
+@57|3|7|,|9| @9|2|1|%|
diff --git a/runtime/syntax/testdir/dumps/tera_03.dump b/runtime/syntax/testdir/dumps/tera_03.dump
new file mode 100644
index 0000000..f5637c7
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_03.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@7|<+0#00e0e07&|m+0#af5f00255&|a|i|n|>+0#00e0e07&| +0#0000000&@60
+@12|{+0#0000e05&|#| |C|o|n|d|i|t|i|o|n|a|l|s| |#|}| +0#0000000&@44
+@12|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|u|s|e|r| |%|}| +0#0000000&@49
+@16|<+0#00e0e07&|s+0#af5f00255&|e|c|t|i|o|n| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|w|e|l|c|o|m|e|"|>+0#00e0e07&| +0#0000000&@33
+@20|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|W+0#e000e06&|e|l|c|o|m|e| |b|a|c|k|,| |{@1| |u|s|e|r|.|n|a|m|e| |}@1|!|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@15
+@20><+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|L+0#0000000&|a|s|t| |l|o|g|i|n|:| |{+0#e000e06&@1| |u+0#00e0e07&|s|e|r|.+0#e000e06&|l+0#00e0e07&|a|s|t|_|l|o|g|i|n| +0#e000e06&||| |d|a|t|e|(|f+0#00e0e07&|o|r|m|a|t|=+0#e000e06&|"+0#e000002&|%|Y|-|%|m|-
+|%|d|"|)+0#e000e06&| |}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@63
+@16|<+0#00e0e07&|/|s+0#af5f00255&|e|c|t|i|o|n|>+0#00e0e07&| +0#0000000&@48
+@12|{+0#e000e06&|%| |e+0#af5f00255&|l|i|f| +0#e000e06&|v|i|s|i|t|o|r|_|c|o|u|n|t| |>+0#af5f00255&| +0#e000e06&|0+0#e000002&| +0#e000e06&|%|}| +0#0000000&@34
+@16|<+0#00e0e07&|s+0#af5f00255&|e|c|t|i|o|n| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|w|e|l|c|o|m|e|"|>+0#00e0e07&| +0#0000000&@33
+@20|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|W+0#e000e06&|e|l|c|o|m|e|,| |v|i|s|i|t|o|r|!|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@28
+@20|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|Y+0#0000000&|o|u| |a|r|e| |v|i|s|i|t|o|r| |n|u|m|b|e|r| |{+0#e000e06&@1| |v+0#00e0e07&|i|s|i|t|o|r|_|c|o|u|n|t| +0#e000e06&|}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@5
+@16|<+0#00e0e07&|/|s+0#af5f00255&|e|c|t|i|o|n|>+0#00e0e07&| +0#0000000&@48
+@12|{+0#e000e06&|%| |e+0#af5f00255&|l|s|e| +0#e000e06&|%|}| +0#0000000&@52
+@16|<+0#00e0e07&|s+0#af5f00255&|e|c|t|i|o|n| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|w|e|l|c|o|m|e|"|>+0#00e0e07&| +0#0000000&@33
+@20|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|W+0#e000e06&|e|l|c|o|m|e| |t|o| |o|u|r| |s|i|t|e|!|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@25
+@16|<+0#00e0e07&|/|s+0#af5f00255&|e|c|t|i|o|n|>+0#00e0e07&| +0#0000000&@48
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@51
+@75
+@57|5|4|,|2|1| @8|3|2|%|
diff --git a/runtime/syntax/testdir/dumps/tera_04.dump b/runtime/syntax/testdir/dumps/tera_04.dump
new file mode 100644
index 0000000..127a258
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_04.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+@12|{+0#0000e05&|#| |M|a|c|r|o| |d|e|f|i|n|i|t|i|o|n| |a|n|d| |u|s|a|g|e| |#|}| +0#0000000&@30
+@12|{+0#e000e06&|%| |m+0#af5f00255&|a|c|r|o| +0#e000e06&|r+0#00e0e07&|e|n|d|e|r|_|i|t|e|m|(+0#e000e06&|i|t|e|m|,| |f|e|a|t|u|r|e|d|=|f+0#e000002&|a|l|s|e|)+0#e000e06&| |%|}| +0#0000000&@17
+@16|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|i|t|e|m| |{@1| |f|e|a|t|u|r|e|d| |?| |'|f|e|a|t|u|r|e|d|'| |:| |'@1| |}@1|"|>+0#00e0e07&| +0#0000000&@7
+@20|<+0#00e0e07&|h+0#af5f00255&|3|>+0#00e0e07&|{+0#e000e06&@1| |i|t|e|m|.|t|i|t|l|e| |}@1|<+0#00e0e07&|/|h+0#af5f00255&|3|>+0#00e0e07&| +0#0000000&@29
+@20><+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|{+0#e000e06&@1| |i+0#00e0e07&|t|e|m|.+0#e000e06&|d+0#00e0e07&|e|s|c|r|i|p|t|i|o|n| +0#e000e06&||| |t|r|u|n|c|a|t|e|(|l+0#00e0e07&|e|n|g|t|h|=+0#e000e06&|1+0#e000002&|0@1|)+0#e000e06&| |}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@2
+@20|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|i|t|e|m|.|t|a|g|s| |%|}| +0#0000000&@36
+@24|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|t|a|g|s|"|>+0#00e0e07&| +0#0000000&@32
+@28|{+0#e000e06&|%| |f+0#af5f00255&|o|r| +0#e000e06&|t|a|g| |i+0#af5f00255&|n| +0#e000e06&|i|t|e|m|.|t|a|g|s| |%|}| +0#0000000&@20
+@32|<+0#00e0e07&|s+0#af5f00255&|p|a|n| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|t|a|g|"|>+0#00e0e07&|{+0#e000e06&@1| |t+0#00e0e07&|a|g| +0#e000e06&|}@1|<+0#00e0e07&|/|s+0#af5f00255&|p|a|n|>+0#00e0e07&| +0#0000000&@8
+@28|{+0#e000e06&|%| |e+0#af5f00255&|n|d|f|o|r| +0#e000e06&|%|}| +0#0000000&@34
+@24|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@44
+@20|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@43
+@16|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@52
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|m|a|c|r|o| +0#e000e06&|r|e|n|d|e|r|_|i|t|e|m| |%|}| +0#0000000&@36
+@75
+@12|{+0#0000e05&|#| |I|t|e|m|s| |s|e|c|t|i|o|n| |w|i|t|h| |m|a|c|r|o| |u|s|a|g|e| |#|}| +0#0000000&@26
+@12|<+0#00e0e07&|s+0#af5f00255&|e|c|t|i|o|n| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|i|t|e|m|s|"|>+0#00e0e07&| +0#0000000&@39
+@16|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|I+0#e000e06&|t|e|m|s| |(|{@1| |i|t|e|m|s| ||| |l|e|n|g|t|h| |}@1|)|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@21
+@57|7|1|,|2|1| @8|4@1|%|
diff --git a/runtime/syntax/testdir/dumps/tera_05.dump b/runtime/syntax/testdir/dumps/tera_05.dump
new file mode 100644
index 0000000..5a3d7a9
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_05.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@15|<+0#00e0e07&|h+0#af5f00255&|2|>+0#00e0e07&|I+0#e000e06&|t|e|m|s| |(|{@1| |i|t|e|m|s| ||| |l|e|n|g|t|h| |}@1|)|<+0#00e0e07&|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@21
+@75
+@16|{+0#e000e06&|%| |f+0#af5f00255&|o|r| +0#e000e06&|i|t|e|m| |i+0#af5f00255&|n| +0#e000e06&|i|t|e|m|s| |%|}| +0#0000000&@35
+@20|{+0#e000e06&@1| |s+0#00e0e07&|e|l|f|:+0#e000e06&@1|r+0#00e0e07&|e|n|d|e|r|_|i|t|e|m|(+0#e000e06&|i+0#00e0e07&|t|e|m|=+0#e000e06&|i+0#00e0e07&|t|e|m|,+0#e000e06&| |f+0#00e0e07&|e|a|t|u|r|e|d|=+0#e000e06&|i+0#00e0e07&|t|e|m|.+0#e000e06&|i+0#00e0e07&|d| +0#e000e06&|=+0#af5f00255&@1| +0#e000e06&|f+0#00e0e07&|e|a
+|t|u|r|e|d|_|i|d|)+0#e000e06&| |}@1| +0#0000000&@62
+> @74
+@20|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|n+0#af5f00255&|o|t| +0#e000e06&|l|o@1|p|.|l|a|s|t| |%|}| +0#0000000&@32
+@24|<+0#00e0e07&|h+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@46
+@20|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@43
+@16|{+0#e000e06&|%| |e+0#af5f00255&|n|d|f|o|r| +0#e000e06&|%|}| +0#0000000&@46
+@12|<+0#00e0e07&|/|s+0#af5f00255&|e|c|t|i|o|n|>+0#00e0e07&| +0#0000000&@52
+@75
+@12|{+0#0000e05&|#| |R|a|w| |c|o|n|t|e|n|t| |t|h|a|t| |s|h|o|u|l|d|n|'|t| |b|e| |p|r|o|c|e|s@1|e|d| |#|}| +0#0000000&@17
+@12|{|%| |r|a|w| |%|}| @53
+@16|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|e|x|a|m|p|l|e|"|>+0#00e0e07&| +0#0000000&@37
+@20|T|h|e| |s|y|n|t|a|x| |{@1| |v|a|r|i|a|b|l|e| |}@1| |w|i|l@1| |n|o|t| |b|e| |p|r|o|c|e|s@1|e|d| |i|n| |r|a|w|
+|b|l|o|c|k|s|.| @67
+@20|N|e|i|t|h|e|r| |w|i|l@1| |{|%| |c|o|n|t|r|o|l| |%|}| |s|t|r|u|c|t|u|r|e|s|.| @16
+@16|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@52
+@57|8@1|,|0|-|1| @7|5|6|%|
diff --git a/runtime/syntax/testdir/dumps/tera_06.dump b/runtime/syntax/testdir/dumps/tera_06.dump
new file mode 100644
index 0000000..96c2e2b
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_06.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@15|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@52
+@12|{|%| |e|n|d|r|a|w| |%|}| @50
+@75
+@12|{+0#0000e05&|#| |I|n|c|l|u|d|e|s| |#|}| +0#0000000&@48
+@12|{+0#e000e06&|%| |i+0#af5f00255&|n|c|l|u|d|e| +0#e000e06&|"+0#e000002&|p|a|r|t|i|a|l|s|/|f|o@1|t|e|r|.|t|e|r|a|"| +0#e000e06&|%|}| +0#0000000&@26
+> @74
+@12|{+0#0000e05&|#| |I|n|h|e|r|i|t|a|n|c|e| |e|x|a|m|p|l|e| |#|}| +0#0000000&@37
+@12|{+0#e000e06&|%| |b+0#af5f00255&|l|o|c|k| +0#e000e06&|c|o|n|t|e|n|t| |%|}| +0#0000000&@43
+@16|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|T+0#0000000&|h|i|s| |i|s| |t|h|e| |d|e|f|a|u|l|t| |c|o|n|t|e|n|t|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@23
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|b|l|o|c|k| +0#e000e06&|c|o|n|t|e|n|t| |%|}| +0#0000000&@40
+@75
+@12|{+0#0000e05&|#| |S|e|t| |v|a|r|i|a|b|l|e|s| |#|}| +0#0000000&@43
+@12|{+0#e000e06&|%| |s+0#af5f00255&|e|t| +0#e000e06&|t|e|x|t|_|c|o|l|o|r| |=| |d|a|r|k|_|m|o|d|e| |?| |"+0#e000002&|#|f@2|"| +0#e000e06&|:| |"+0#e000002&|#|3@2|"| +0#e000e06&|%|}| +0#0000000&@12
+@12|{+0#e000e06&|%| |s+0#af5f00255&|e|t| +0#e000e06&|i|t|e|m|s|_|c|o|u|n|t| |=| |i|t|e|m|s| ||| |l|e|n|g|t|h| |%|}| +0#0000000&@24
+@75
+@12|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|s+0#00e0003&|t|y|l|e|=+0#00e0e07&|"+0#e000002&|c|o|l|o|r|:| |{@1| |t|e|x|t|_|c|o|l|o|r| |}@1|"|>+0#00e0e07&| +0#0000000&@25
+@16|W|e| |h|a|v|e| |{+0#e000e06&@1| |i+0#00e0e07&|t|e|m|s|_|c|o|u|n|t| +0#e000e06&|}@1| +0#0000000&|i|t|e|m|s|.| @26
+@12|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@56
+@75
+@57|1|0|5|,|0|-|1| @6|6|7|%|
diff --git a/runtime/syntax/testdir/dumps/tera_07.dump b/runtime/syntax/testdir/dumps/tera_07.dump
new file mode 100644
index 0000000..b7190d7
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_07.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+@12|{+0#0000e05&|#| |F|i|l|t|e|r|s| |w|i|t|h| |c|o|m|p|l|e|x| |e|x|p|r|e|s@1|i|o|n|s| |#|}| +0#0000000&@24
+@12|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|{+0#e000e06&@1| |"+0#e000002&|H|e|l@1|o|,| |"| +0#e000e06&|~| |u+0#00e0e07&|s|e|r|.+0#e000e06&|n+0#00e0e07&|a|m|e| +0#e000e06&||| |d|e|f|a|u|l|t|(|v+0#00e0e07&|a|l|u|e|=+0#e000e06&|"+0#e000002&|G|u|e|s|t|"|)+0#e000e06&| ||| |u|p@1|e|r| |}@1
+|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@70
+@12|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|{+0#e000e06&@1| |i+0#00e0e07&|t|e|m|s| +0#e000e06&||| |f|i|l|t|e|r|(|a+0#00e0e07&|t@1|r|i|b|u|t|e|=+0#e000e06&|"+0#e000002&|f|e|a|t|u|r|e|d|"|,+0#e000e06&| |v+0#00e0e07&|a|l|u|e|=+0#e000e06&|t+0#e000002&|r|u|e|)+0#e000e06&| ||| |l|e|n|g|t|h
+| |}@1| +0#0000000&|f|e|a|t|u|r|e|d| |i|t|e|m|s|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@52
+> @74
+@12|{+0#0000e05&|#| |W|i|t|h| |s|t|a|t|e|m|e|n|t| |#|}| +0#0000000&@42
+@12|{+0#e000e06&|%| |w+0#af5f00255&|i|t|h| +0#e000e06&|%|}| +0#0000000&@52
+@16|{+0#e000e06&|%| |s+0#af5f00255&|e|t| +0#e000e06&|l|o|c|a|l|_|v|a|r| |=| |"+0#e000002&|O|n|l|y| |v|i|s|i|b|l|e| |i|n| |t|h|i|s| |s|c|o|p|e|"| +0#e000e06&|%|}| +0#0000000&@8
+@16|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|{+0#e000e06&@1| |l+0#00e0e07&|o|c|a|l|_|v|a|r| +0#e000e06&|}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@36
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|w|i|t|h| +0#e000e06&|%|}| +0#0000000&@49
+@75
+@12|{+0#0000e05&|#| |M|a|t|h|e|m|a|t|i|c|a|l| |o|p|e|r|a|t|i|o|n|s| |#|}| +0#0000000&@33
+@12|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|m|a|t|h|"|>+0#00e0e07&| +0#0000000&@44
+@16|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|r|i|c|e|:| |$|{+0#e000e06&@1| |p+0#00e0e07&|r|i|c|e| +0#e000e06&|}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@32
+@16|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|T+0#0000000&|a|x| |(|{+0#e000e06&@1| |t+0#00e0e07&|a|x|_|r|a|t|e| +0#e000e06&|*+0#af5f00255&| +0#e000e06&|1+0#e000002&|0@1| +0#e000e06&|}@1|%+0#0000000&|)|:| |$|{+0#e000e06&@1| |p+0#00e0e07&|r|i|c|e| +0#e000e06&|*+0#af5f00255&| +0#e000e06&|t+0#00e0e07&|a|x|_|r|a|t|e| +0#e000e06&|}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&
+| +0#0000000&@15|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|T+0#0000000&|o|t|a|l|:| |$|{+0#e000e06&@1| |p+0#00e0e07&|r|i|c|e| +0#e000e06&|*+0#af5f00255&| +0#e000e06&|(|1+0#e000002&| +0#e000e06&|++0#af5f00255&| +0#e000e06&|t+0#00e0e07&|a|x|_|r|a|t|e|)+0#e000e06&| |}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@15
+@12|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@56
+@57|1|2@1|,|0|-|1| @6|7|9|%|
diff --git a/runtime/syntax/testdir/dumps/tera_08.dump b/runtime/syntax/testdir/dumps/tera_08.dump
new file mode 100644
index 0000000..1231ed1
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_08.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@11|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@56
+@75
+@12|{+0#0000e05&|#| |B|o@1|l|e|a|n| |o|p|e|r|a|t|i|o|n|s| |#|}| +0#0000000&@38
+@12|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|u|s|e|r| |a+0#af5f00255&|n|d| +0#e000e06&|u|s|e|r|.|i|s|_|a|d|m|i|n| |o+0#af5f00255&|r| +0#e000e06&|s|u|p|e|r|_|u|s|e|r| |%|}| +0#0000000&@17
+@16|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|a|d|m|i|n|-|p|a|n|e|l|"|>+0#00e0e07&|A+0#0000000&|d|m|i|n| |p|a|n|e|l|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@16
+@12>{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@51
+@8|<+0#00e0e07&|/|m+0#af5f00255&|a|i|n|>+0#00e0e07&| +0#0000000&@59
+@75
+@8|{+0#0000e05&|#| |F|o@1|t|e|r| |s|e|c|t|i|o|n| |w|i|t|h| |f|i|l|t|e|r|s| |a|n|d| |i|n|c|l|u|d|e|s| |#|}| +0#0000000&@20
+@8|<+0#00e0e07&|f+0#af5f00255&|o@1|t|e|r|>+0#00e0e07&| +0#0000000&@58
+@12|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|&+0#e000e06&|c|o|p|y|;| +0#0000000&|{+0#e000e06&@1| |c+0#00e0e07&|u|r@1|e|n|t|_|y|e|a|r| +0#e000e06&|}@1| +0#0000000&|{+0#e000e06&@1| |c+0#00e0e07&|o|m|p|a|n|y|_|n|a|m|e| +0#e000e06&||| |d|e|f|a|u|l|t|(|v+0#00e0e07&|a|l|u|e|=+0#e000e06&|"+0#e000002&|O
+|u|r| |C|o|m|p|a|n|y|"|)+0#e000e06&| |}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@55
+@75
+@12|{+0#e000e06&|%| |i+0#af5f00255&|f| +0#e000e06&|d|e|b|u|g| |%|}| +0#0000000&@48
+@16|<+0#00e0e07&|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|d|e|b|u|g|-|i|n|f|o|"|>+0#00e0e07&| +0#0000000&@34
+@20|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|R+0#0000000&|e|n|d|e|r| |t|i|m|e|:| |{+0#e000e06&@1| |r+0#00e0e07&|e|n|d|e|r|_|t|i|m|e| +0#e000e06&|}@1|m+0#0000000&|s|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@15
+@20|<+0#00e0e07&|p+0#af5f00255&|>+0#00e0e07&|T+0#0000000&|e|m|p|l|a|t|e| |v|e|r|s|i|o|n|:| |{+0#e000e06&@1| |v+0#00e0e07&|e|r|s|i|o|n| +0#e000e06&|}@1|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@16
+@16|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@52
+@12|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@51
+@57|1|3|9|,|1|3| @7|9|0|%|
diff --git a/runtime/syntax/testdir/dumps/tera_09.dump b/runtime/syntax/testdir/dumps/tera_09.dump
new file mode 100644
index 0000000..55cb518
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tera_09.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@11|{+0#e000e06&|%| |e+0#af5f00255&|n|d|i|f| +0#e000e06&|%|}| +0#0000000&@51
+@8|<+0#00e0e07&|/|f+0#af5f00255&|o@1|t|e|r|>+0#00e0e07&| +0#0000000&@57
+@4|<+0#00e0e07&|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@64
+@75
+@4|<+0#00e0e07&|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&| +0#0000000&@62
+| +0#e000e06&@7>c+0#af5f00255&|o|n|s|t| +0#e000e06&|a|p@1|D|a|t|a| |=| |{+0#00e0e07&| +0#0000000&@49
+| +0#e000e06&@11|"+0#e000002&|u|s|e|r|"|:+0#e000e06&| |{+0#00e0e07&|%+0#e000e06&| |i+0#af5f00255&|f| +0#e000e06&|u|s|e|r| |%|}+0#00e0e07&|{@1| +0#e000e06&|u|s|e|r| ||| |j|s|o|n|_|e|n|c|o|d|e|(+0#0000000&|)| +0#e000e06&|}+0#00e0e07&@1|{|%+0#e000e06&| |e+0#af5f00255&|l|s|e| +0#e000e06&|%|}+0#00e0e07&|n+0#af5f00255&|u|l@1|{+0#00e0e07&|%+0#e000e06&
+| |e|n|d|i|f| |%|}+0#00e0e07&|,+0#e000e06&| +0#0000000&@64
+| +0#e000e06&@11|"+0#e000002&|s|e|t@1|i|n|g|s|"|:+0#e000e06&| |{+0#00e0e07&| +0#0000000&@49
+| +0#e000e06&@15|"+0#e000002&|t|h|e|m|e|"|:+0#e000e06&| |"+0#e000002&|{@1| |t|h|e|m|e| ||| |d|e|f|a|u|l|t|(|v|a|l|u|e|=|"|l+0#e000e06&|i|g|h|t|"+0#e000002&|)| |}@1|"|,+0#e000e06&| +0#0000000&@10
+| +0#e000e06&@15|"+0#e000002&|n|o|t|i|f|i|c|a|t|i|o|n|s|"|:+0#e000e06&| |{+0#00e0e07&@1| +0#e000e06&|n|o|t|i|f|i|c|a|t|i|o|n|s|_|e|n|a|b|l|e|d| ||| |s+0#00e0003&|t|r|i|n|g| +0#e000e06&||| |l|o|w|e|r|
+|}+0#00e0e07&@1| +0#0000000&@72
+| +0#e000e06&@11|}+0#00e0e07&| +0#0000000&@61
+| +0#e000e06&@7|}+0#00e0e07&|;+0#e000e06&| +0#0000000&@64
+| +0#e000e06&@3|<+0#00e0e07&|/|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&| +0#0000000&@61
+|<+0#00e0e07&|/|b+0#af5f00255&|o|d|y|>+0#00e0e07&| +0#0000000&@67
+|<+0#00e0e07&|/|h+0#af5f00255&|t|m|l|>+0#00e0e07&| +0#0000000&@67
+|~+0#4040ff13&| @73
+|~| @73
+| +0#0000000&@56|1|5|6|,|9| @8|B|o|t|
diff --git a/runtime/syntax/testdir/input/tera.tera b/runtime/syntax/testdir/input/tera.tera
new file mode 100644
index 0000000..161793c
--- /dev/null
+++ b/runtime/syntax/testdir/input/tera.tera
@@ -0,0 +1,165 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>{{ page_title | default(value="Tera Test") }}</title>
+ {% if include_styles %}
+ <style>
+ body {
+ font-family: {{ font_family | default(value="sans-serif") }};
+ color: #333;
+ line-height: 1.6;
+ }
+ .container {
+ width: 80%;
+ margin: 0 auto;
+ }
+ {% if dark_mode %}
+ body {
+ background-color: #222;
+ color: #eee;
+ }
+ {% endif %}
+ </style>
+ {% endif %}
+</head>
+<body>
+ <div class="container">
+ {# Header Section with variable interpolation #}
+ <header>
+ <h1>{{ header_text | upper }}</h1>
+ {% if subheader %}
+ <h2>{{ subheader }}</h2>
+ {% endif %}
+ </header>
+
+ {# Navigation example with for loop #}
+ <nav>
+ <ul>
+ {% for item in navigation %}
+ <li class="{{ loop.index0 == current_page ? 'active' : '' }}">
+ <a href="{{ item.url }}">{{ item.title }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </nav>
+
+ {# Main content section with various template features #}
+ <main>
+ {# Conditionals #}
+ {% if user %}
+ <section class="welcome">
+ <h2>Welcome back, {{ user.name }}!</h2>
+ <p>Last login: {{ user.last_login | date(format="%Y-%m-%d") }}</p>
+ </section>
+ {% elif visitor_count > 0 %}
+ <section class="welcome">
+ <h2>Welcome, visitor!</h2>
+ <p>You are visitor number {{ visitor_count }}</p>
+ </section>
+ {% else %}
+ <section class="welcome">
+ <h2>Welcome to our site!</h2>
+ </section>
+ {% endif %}
+
+ {# Macro definition and usage #}
+ {% macro render_item(item, featured=false) %}
+ <div class="item {{ featured ? 'featured' : '' }}">
+ <h3>{{ item.title }}</h3>
+ <p>{{ item.description | truncate(length=100) }}</p>
+ {% if item.tags %}
+ <div class="tags">
+ {% for tag in item.tags %}
+ <span class="tag">{{ tag }}</span>
+ {% endfor %}
+ </div>
+ {% endif %}
+ </div>
+ {% endmacro render_item %}
+
+ {# Items section with macro usage #}
+ <section class="items">
+ <h2>Items ({{ items | length }})</h2>
+
+ {% for item in items %}
+ {{ self::render_item(item=item, featured=item.id == featured_id) }}
+
+ {% if not loop.last %}
+ <hr>
+ {% endif %}
+ {% endfor %}
+ </section>
+
+ {# Raw content that shouldn't be processed #}
+ {% raw %}
+ <div class="example">
+ The syntax {{ variable }} will not be processed in raw blocks.
+ Neither will {% control %} structures.
+ </div>
+ {% endraw %}
+
+ {# Includes #}
+ {% include "partials/footer.tera" %}
+
+ {# Inheritance example #}
+ {% block content %}
+ <p>This is the default content.</p>
+ {% endblock content %}
+
+ {# Set variables #}
+ {% set text_color = dark_mode ? "#fff" : "#333" %}
+ {% set items_count = items | length %}
+
+ <div style="color: {{ text_color }}">
+ We have {{ items_count }} items.
+ </div>
+
+ {# Filters with complex expressions #}
+ <p>{{ "Hello, " ~ user.name | default(value="Guest") | upper }}</p>
+ <p>{{ items | filter(attribute="featured", value=true) | length }} featured items</p>
+
+ {# With statement #}
+ {% with %}
+ {% set local_var = "Only visible in this scope" %}
+ <p>{{ local_var }}</p>
+ {% endwith %}
+
+ {# Mathematical operations #}
+ <div class="math">
+ <p>Price: ${{ price }}</p>
+ <p>Tax ({{ tax_rate * 100 }}%): ${{ price * tax_rate }}</p>
+ <p>Total: ${{ price * (1 + tax_rate) }}</p>
+ </div>
+
+ {# Boolean operations #}
+ {% if user and user.is_admin or super_user %}
+ <div class="admin-panel">Admin panel</div>
+ {% endif %}
+ </main>
+
+ {# Footer section with filters and includes #}
+ <footer>
+ <p>© {{ current_year }} {{ company_name | default(value="Our Company") }}</p>
+
+ {% if debug %}
+ <div class="debug-info">
+ <p>Render time: {{ render_time }}ms</p>
+ <p>Template version: {{ version }}</p>
+ </div>
+ {% endif %}
+ </footer>
+ </div>
+
+ <script>
+ const appData = {
+ "user": {% if user %}{{ user | json_encode() }}{% else %}null{% endif %},
+ "settings": {
+ "theme": "{{ theme | default(value="light") }}",
+ "notifications": {{ notifications_enabled | string | lower }}
+ }
+ };
+ </script>
+</body>
+</html>