Repository navigation
Conversation
{{~! comment ~}} and {{~!-- comment --~}} failed to parse, and a ~ before
the closing braces of a compact comment was kept as comment text. Accept
the tildes in the comment rules and strip the surrounding whitespace like
for other tags. A comment also resets the whitespace omission of the tag
before it, as in handlebars.js.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comments don't accept the
~whitespace control that every other tag takes, so templates written for handlebars.js fail to compile:handlebars.js renders
ab.{{~!-- comment --~}}fails the same way, and{{! comment ~}}parses but keeps the whitespace because the~ends up in the comment text.This allows a
~after the opening{{and before the closing}}of both comment forms in the grammar. The template builder then strips the whitespace on that side, the same way it does for expressions. A comment now also setsomit_pro_wsfrom its own closing tag, so{{foo~}}{{! comment }} bkeeps the spaces after the comment like handlebars.js (bar b). Before, the earlier~carried over the comment and removed them.Tests:
test_comment_whitespace_controlintests/whitespace.rscovers both comment forms with~on either side, a comment containing}}, a standalone comment with a trailing~, and the~that must not carry over a comment. The expected strings are what handlebars.js 4.7.10 renders. The test fails on master with the parse error above and passes with the change.cargo test --all-features,cargo clippy --all-features --all-targets -- -D warningsandcargo fmt -- --checkpass.