diff --git a/lib/Cro/WebApp/Template/ASTBuilder.rakumod b/lib/Cro/WebApp/Template/ASTBuilder.rakumod index 9d8b16d..044f24d 100644 --- a/lib/Cro/WebApp/Template/ASTBuilder.rakumod +++ b/lib/Cro/WebApp/Template/ASTBuilder.rakumod @@ -79,9 +79,25 @@ class Cro::WebApp::Template::ASTBuilder { make Literal.new(text => ~$/); } - method sigil-tag:sym($/) { - make Nothing.new; + make Nothing.new; + } + + # cw: These are reversed for some reason... I don't know why! + method sigil-tag:sym($/) { + make Literal.new( text => '<=' ); + } + + method sigil-tag:sym($/) { + make Literal.new( text => '>=' ); + } + + method sigil-tag:sym($/) { + make Literal.new( text => '>' ); + } + + method sigil-tag:sym($/) { + make Literal.new( text => '<' ); } method sigil-tag:sym($/) { diff --git a/lib/Cro/WebApp/Template/Parser.rakumod b/lib/Cro/WebApp/Template/Parser.rakumod index bb1adc4..d174e21 100644 --- a/lib/Cro/WebApp/Template/Parser.rakumod +++ b/lib/Cro/WebApp/Template/Parser.rakumod @@ -49,6 +49,8 @@ grammar Cro::WebApp::Template::Parser { [ '>' || <.panic: "malformed closing tag"> ] } + + proto token tag-element { * } token tag-element:sym { @@ -66,6 +68,11 @@ grammar Cro::WebApp::Template::Parser { proto token sigil-tag { * } + token sigil-tag:sym { '<\ge>' } + token sigil-tag:sym { '<\le>' } + token sigil-tag:sym { '<\gt>' } + token sigil-tag:sym { '<\lt>' } + token sigil-tag:sym { '<.' [ || <.malformed: 'topic tag'> ] diff --git a/t/template-use.rakutest b/t/template-use.rakutest index c1564d7..fafc269 100644 --- a/t/template-use.rakutest +++ b/t/template-use.rakutest @@ -41,6 +41,17 @@ is norm-ws(render-template('transitive-use.crotmp', {})), EXPECTED +is norm-ws(render-template('ab-test-1.crotmp', {})), + norm-ws(q:to/EXPECTED/), 'Can call a sub from a used template'; +
+ Foo bar header<<= +
+ Content +
+ Foo bar footer>>= +
+ EXPECTED + sub norm-ws($str) { $str.subst(:g, /\s+/, '') } diff --git a/t/test-data/ab-test-1.crotmp b/t/test-data/ab-test-1.crotmp new file mode 100644 index 0000000..cc7377d --- /dev/null +++ b/t/test-data/ab-test-1.crotmp @@ -0,0 +1,4 @@ +<:use 'angle-bracket-escape.crotmp'> +<&header> +Content +<&footer> diff --git a/t/test-data/angle-bracket-escape.crotmp b/t/test-data/angle-bracket-escape.crotmp new file mode 100644 index 0000000..7cf0ee6 --- /dev/null +++ b/t/test-data/angle-bracket-escape.crotmp @@ -0,0 +1,19 @@ +<:sub footer> +
+ Foo bar footer<\gt><\ge> +
+ + +<:sub header> +
+ Foo bar header<\lt><\le> +
+ + +<:macro wrap> + + <&header><\le><\ge> + <:body> + <&footer> + +