-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix treatment of standalone tags. #15
Conversation
Lines containing ^, /, !, <, or = tags should be stripped from the output if the tags are standalone. The least intrusive way to handle this I could find was to simply "expand" the endpoints of such tags to fill the line - all existing logic will continue to just work. This fixes 29 spec test failures.
@@ -386,20 +386,26 @@ Tag Renderer::findTag(const QString& content, int pos, int endPos) | |||
if (typeChar == '#') { | |||
tag.type = Tag::SectionStart; | |||
tag.key = readTagName(content, pos+1, endPos); | |||
expandTag(tag, content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these duplicated expandTag() calls be replaced with a 'if (tag.type != Tag::Value) { /* expand tag */ }' test after if () else ... block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Fixed.
(I guess I was thinking in case a new tag type appears it's less likely to bring in unwanted behavior for it. But that's probably very unlikely.)
* | ||
* A tag is standalone if it is the only non-whitespace token on the the line. | ||
*/ | ||
void expandTag(Tag& tag, const QString &content) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit - coding convention in mustache.h/cpp is 'const T&' rather than 'const T &'. This function can also be static since it doesn't read or modify any fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Good to go? I have a fix for standalone partials indentation to follow this up with :) |
Fix treatment of standalone tags.
Yup - Thanks again @estan! |
Lines containing ^, /, !, <, or = tags should be stripped from the output if the tags are standalone. The least intrusive way to handle this I could find was to simply "expand" the endpoints of such tags to fill the line - all existing logic will continue to just work.
This fixes 29 spec test failures.
I think all the 13 remaining failures fall into one of these categories:
I'll might try to tackle the last one next.