Skip to content
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

Spec fixes #6

Merged
merged 3 commits into from Aug 18, 2014
Merged

Spec fixes #6

merged 3 commits into from Aug 18, 2014

Conversation

estan
Copy link
Contributor

@estan estan commented Aug 14, 2014

Allow whitespace between '=' and delimiter.

Currently, qt-mustache will not allow any whitespace between the = signs and the start/end delimiter in set delimiter tags. It will treat such whitespace as being part of the delimiters and yield the error "Custom delimiters may not contain '=' or spaces.".

Apparently, even though the specification reads

"The tag's content MUST be any two non-whitespace sequences
 (separated by whitespace) EXCEPT an equals sign ('=') followed
 by the current closing delimiter.",

apparently such whitespace should ignored. E.g. tags such as

{{= [ ] =}}

should be allowed. The spec is slightly ambiguos here I think, but that is apparently the intention.

This patch changes readSetDelimiter(..) to ignore such whitespace. As a result the "Pair with Padding" test case in delimiters.json now passes, since it has such a set delimiter tag. The "Sections" test case in the same file have one as well, and would also pass now if we only handled standalone tags properly.

Currently, qt-mustache will not allow any whitespace between the =
signs and the start/end delimiter in set delimiter tags. It will
treat such whitespace as being part of the delimiters and yield the
error "Custom delimiters may not contain '=' or spaces.".

Apparently, even though the specification reads

    "The tag's content MUST be any two non-whitespace sequences
     (separated by whitespace) EXCEPT an equals sign ('=') followed
     by the current closing delimiter." [1],

apparently such whitespace should ignored. E.g. tags such as

    {{= [ ] =}}

should be allowed [2]. The spec is slightly ambiguos here I think,
but that is apparently the intention.

This patch changes `readSetDelimiter(..)` to ignore such whitespace.
As a result the "Pair with Padding" test case in `delimiters.json`
now passes, since it has such a set delimiter tag. The "Sections"
test case in the same file have one as well, and would also pass
now if we only handled standalone tags properly.

[1] https://github.com/mustache/spec/blob/v1.1.2/specs/delimiters.yml#L5-L7
[2] mustache/spec#29
Currently, qt-mustache will not allow any whitespace between the =
signs and the start/end delimiter in set delimiter tags. It will
treat such whitespace as being part of the delimiters and yield the
error "Custom delimiters may not contain '=' or spaces.".

Apparently, even though the specification reads

    "The tag's content MUST be any two non-whitespace sequences
     (separated by whitespace) EXCEPT an equals sign ('=') followed
     by the current closing delimiter." [1],

apparently such whitespace should ignored. E.g. tags such as

    {{= [ ] =}}

should be allowed [2]. The spec is slightly ambiguos here I think,
but that is apparently the intention.

This patch changes `readSetDelimiter(..)` to ignore such whitespace.
As a result the "Pair with Padding" test case in `delimiters.json`
now passes, since it has such a set delimiter tag. The "Sections"
test case in the same file have one as well, and would also pass
now if we only handled standalone tags properly.

[1] https://github.com/mustache/spec/blob/v1.1.2/specs/delimiters.yml#L5-L7
[2] mustache/spec#29
robertknight added a commit that referenced this pull request Aug 18, 2014
Spec fixes - Allow whitespace between '=' and start/end of delimiter when reading custom delimiters.
@robertknight robertknight merged commit 8ee9aa2 into robertknight:master Aug 18, 2014
@robertknight
Copy link
Owner

Thanks. A small issue which was present in the original code is that comparisons between a QChar and an ASCII literal should wrap the char in QLatin1Char() or use unicode(). Otherwise an expensive conversion from the local 8 bit encoding is used.

eg. 'someString.at(index) == QLatin1Char('=')'.

This is just a potential micro-optimization though.

@estan estan deleted the spec-fixes branch August 18, 2014 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants