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
{{ message }}
Repository navigation
ifs are not evaluated if there are invisible characters #605
In case there are invisible characters (in this case it is a BOM) in an if statement, Handlebars compiles the template without any errors. But the if is not evaluated.
Expected behavior:
I expect that the if would be evaluated.
Test to reproduce
[Fact]publicvoidCompiles_Ifs_Correctly(){stringsource=@"<div class=""entry""><h1>{{title}}</h1><div class=""body"">{{body}}{{#if someCondition\uFEFF}}<p>Show additional text</p>{{/if}}</div></div>";varhandlebars=Handlebars.Create();vartemplate=handlebars.Compile(source);vardata=new{title="My new post",body="This is my first post!",someCondition=true};varactual=template(data);stringexpected=@"<div class=""entry""><h1>My new post</h1><div class=""body"">This is my first post!<p>Show additional text</p></div></div>";Assert.Equal(expected,actual);}
Other related info
This happens to us as we allow admin users to manually edit the templates and sometimes they manage to insert invisible characters like byte order marks into the template.
After submitting the issue
Please consider contributing to the project by submitting a PR with a fix to the issue.
This would help to solve your problem in a shorter time as well as help other users of the project.
-> Pointers for contributing this fix would be appreciated.
Activity
fix: strip invisible unicode chars (BOM etc.) from identifiers (issue #…
Merge pull request #617 from Handlebars-Net/worktree-agent-a367ce9366…