You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a string in a template, which contains a \ as last character (even escaped as "\\") the renderer fails with an InvalidSyntax error.
Not sure if this is an intended behaviour, but it definitly feels like a bug and is also not the case in other parsers (like handlebars.js). Sorry if there is already another topic describing this, I have'nt found it.
here is an example which reproduces the bug:
#[macro_use]externcrate handlebars;use std::collections::BTreeMap;use handlebars::Handlebars;handlebars_helper!(replace: |input: str, from: str, to: str| {
input.replace(from, to)});// Error when having a \ as last character in a stringfnmain(){let data = BTreeMap::<String,String>::new();letmut bars = Handlebars::new();
bars.register_helper("replace",Box::new(replace));// Replace a / with a \// Works with "\\ " (if the character, before the quote is not a "\" )println!("{}", bars.render_template(r#"{{replace "some/path" "/" "\\ " }}"#, &data).unwrap());// worksprintln!("{}", bars.render_template(r#"{{replace "some/path" "/" "\\something else" }}"#, &data).unwrap());// works// Fails otherwiseprintln!("{}", bars.render_template(r#"{{replace "some/path" "/" "\\" }}"#, &data).unwrap());// failsprintln!("{}", bars.render_template(r#"{{replace "some/path" "/" "something before \\" }}"#, &data).unwrap());// fails}
The text was updated successfully, but these errors were encountered:
When defining a string in a template, which contains a
\
as last character (even escaped as"\\"
) the renderer fails with anInvalidSyntax
error.Not sure if this is an intended behaviour, but it definitly feels like a bug and is also not the case in other parsers (like handlebars.js). Sorry if there is already another topic describing this, I have'nt found it.
here is an example which reproduces the bug:
The text was updated successfully, but these errors were encountered: