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

Allow handlebar syntax errors in raw blocks #64

Closed
wants to merge 6 commits into from

Conversation

JoNil
Copy link

@JoNil JoNil commented Feb 21, 2016

No description provided.

@sunng87
Copy link
Owner

sunng87 commented Feb 22, 2016

Thanks, this is better approach for {{raw}} indeed.

@@ -39,4 +13,49 @@ mod test {
let r = handlebars.render("t0", &());
assert_eq!(r.ok().unwrap(), "a{{content}}{{else}}hello");
}

Copy link
Owner

Choose a reason for hiding this comment

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

You can remove this file and move these tests to template.rs because {{raw}} is no longer a helper.

@TimNN
Copy link
Contributor

TimNN commented Feb 22, 2016

I'm not very familiar with the code, but how will this handle nested {{#raw}} elements?

From reading over the code I believe that right now, if the parser encounters two consecutive opening raw tags (ie: {{#raw}}{{#raw}}), it will be unable to ever exit the raw state.

I don't know what the desired / expected behaviour is, but I believe that either reporting an error or resuming normal parsing after the first {{/raw}} are preferable and easily implemented.

@JoNil
Copy link
Author

JoNil commented Feb 22, 2016

That is true. I willl fix that!

I have no idea what the expected behaviour is for "{{#raw}}{{#raw}}{{/raw}}{{/raw}}".

@sunng87
Copy link
Owner

sunng87 commented Feb 23, 2016

Oh.. Seems handlebars has a new syntax for raw block in 4.0:

Raw blocks are available for templates needing to handle unprocessed mustache blocks.
{{{{raw-helper}}}}
{{bar}}
{{{{/raw-helper}}}}
will execute the helper raw-helper without interpreting the content.
Handlebars.registerHelper('raw-helper', function(options) {
return options.fn();
});
will render
{{bar}}

http://handlebarsjs.com/block_helpers.html#raw-blocks

Overall, it's a new helper with syntax {{{{help-name}}}}, which could access its raw content as text instead of template.

I suggest to implement this new syntax instead of maintaining our own. WDYT, @JoNil ? Let me know if you want to take the task otherwise I will start to think about it ;-)

@sunng87
Copy link
Owner

sunng87 commented Feb 23, 2016

#65

@JoNil
Copy link
Author

JoNil commented Feb 24, 2016

I don't have nearly enough time to work on it unfortunately :(

@sunng87
Copy link
Owner

sunng87 commented Feb 24, 2016

@JoNil Thank you all the same, for this great patch that inspired me to improve the raw helper.

I'm going to close this PR for now. And please let me know if I can help on anything about this library. Thanks!

@sunng87 sunng87 closed this Feb 24, 2016
@sunng87 sunng87 mentioned this pull request Mar 7, 2016
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

3 participants