Space required between block helper close and open tags
We found that this is causing the template to fail:
{{#is ProgramID ""}}no program{{/is}}{{#is ProgramID "1081"}}some program text{{/is}}
However, when we format it with a space between the block close tag and block open tag, it works.
{{#is ProgramID ""}}no program{{/is}} {{#is ProgramID "1081"}}some program text{{/is}}
Any ideas?
I tried to reproduce this as best I can (I am not sure what the #is helper does, though I can guess) - and it seems to work fine. Can you provide more details? i.e. What does "fail" mean?
The helper code:
Handlebars.RegisterHelper("is", (writer, options, context, arguments) => { try { var current = arguments[0].NullSafeToString(); var compare = arguments[1].NullSafeToString(); if (current == compare) { options.Template(writer, (object)context); } else { options.Inverse(writer, (object)context); } } catch { //do something } });
When I call Handlebars.compile, it generates the error:
Non-empty collection required Parameter name: expressions
Only two things I can think of that have made my test cases pass and someone else's fail:
- Can you confirm that is the exact template you're testing?
- Are you using Windows (I'm on Mac, every once in awhile they are slightly different)
This is odd. I did a little more digging myself and can confirm that it works fine if my template has only the 2 "is" helpers with no space. I can't provide the whole template as my client might not be happy with me. I'll have to do more investigating to see what's causing the issue. Meanwhile, at least we have a workaround of adding the space between the helper close/open tags.