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

Support whitespace control in comment blocks, close #332 #632

Merged
merged 2 commits into from
Jan 13, 2016

Conversation

oyyd
Copy link
Contributor

@oyyd oyyd commented Jan 10, 2016

Seems like jingja2 also supports whitespace control in variable blocks. Should nunjucks support that too?

trimBlocks and lstripBlocks only works in statement blocks({% %}). Maybe They also should be supported in other blocks.

((nextToken.type === lexer.TOKEN_BLOCK_START &&
nextVal.charAt(nextVal.length - 1) === '-') ||
(nextToken.type === lexer.TOKEN_COMMENT &&
nextVal.charAt(this.tokens.tags.COMMENT_START.length)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose to use this.tokens.tags.COMMENT_START.length here instead of nextVal.length - 1 as used in the existing clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the TOKEN_COMMENT contains COMMENT_START and COMMENT_END. It's a whole token so that the nextVal here is not {%{#.

Maybe breaking the TOKEN_COMMENT into three parts would be better. But It need change more code so that I use the tag instead.

@carljm
Copy link
Contributor

carljm commented Jan 13, 2016

Looks good, thanks! I had one question in review, but I don't need an answer before merging.

And yes, I would prefer to match Jinja in supporting whitespace control for variable substitutions as well.

carljm added a commit that referenced this pull request Jan 13, 2016
Support whitespace control in comment blocks, close #332
@carljm carljm merged commit 0b6dd68 into mozilla:master Jan 13, 2016
carljm added a commit that referenced this pull request Jan 14, 2016
Support whitespace control in comment blocks, close #332
@oyyd
Copy link
Contributor Author

oyyd commented Jan 14, 2016

Matching jinja would be nice 👍 .

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.

2 participants