Skip to content

Commit

Permalink
Merge pull request #49 from croservices/handle-comments
Browse files Browse the repository at this point in the history
Present the simplest way to handle comments
  • Loading branch information
jnthn committed Jul 21, 2021
2 parents 89b545d + 4237fe7 commit 9c03234
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Cro/WebApp/Template/Parser.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ grammar Cro::WebApp::Template::Parser {
}

token tag-element:sym<literal> {
<-[<>]>+
| '!--' .*? '--' <?before '>'>
| <-[<>]>+
}

proto token sigil-tag { * }
Expand Down
7 changes: 6 additions & 1 deletion t/template-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,16 @@ is norm-ws(render-template($base.add('comments.crotmp'), {})),
<!-- HTML comment -->
<div>Something else</div>
<!--
multi-line HTML comment
multi-line HTML--comment
-->
<p>And that's it<!--really--></p>
EXPECTED

is norm-ws(render-template($base.add('comments-integration.crotmp'), {})),
norm-ws(q:to/EXPECTED/), 'Is not confused by HTML bits commented out';
<html><!--<articleclass="messageis-small"><divclass="message--body">--><!--</div></article>--></html>
EXPECTED

sub norm-ws($str) {
$str.subst(:g, /\s+/, '')
}
Expand Down
6 changes: 6 additions & 0 deletions t/test-data/comments-integration.crotmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<!--<article class="message is-small">
<div class="message--body">-->
<!--</div>
</article>-->
</html>
2 changes: 1 addition & 1 deletion t/test-data/comments.crotmp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- HTML comment -->
<div>Something else</div>
<!--
multi-line HTML comment
multi-line HTML -- comment
-->
<p>And that's it<!--really--></p>

0 comments on commit 9c03234

Please sign in to comment.