Tuesday, 15 May 2012

javascript - Requirejs Handlebar plugin empty lines -


I do not know that this is specific to the requsjs handlebar plugin, but when I have a template: <> pre & lt; H1 & gt; ABC & lt; / H1> {{#if testcondition1}} & lt; H1 & gt; Df & lt; / H1> {{/ If}} {{#if testcondition2}} & lt; H1 & gt; Ghi & lt; / H1> {{/ If}} & lt; H1 & gt; Xyz & lt; / H1>

If a condition is false then I get an empty line like i:

   & Lt; H1 & gt; GHI & lt; / H1> & Lt; H1 & gt; Xyz & lt; / H1>   

no more

  & lt; H1 & gt; ABC & lt; / H1> & Lt; H1 & gt; GHI & lt; / H1> & Lt; H1 & gt; Xyz & lt; / H1>   

Is this expected behavior? I want to get recurring lines without string manipulation after the template compilation. I know the lines are ignored in HTML but this can be particularly troubling in the loop.

If you see new placements in your code:

  & Lt; H1 & gt; ABC & lt; / H1> \ N {{#if testcondition1}} \ n & lt; H1 & gt; Df & lt; / H1> \ N {{/ If}} \ n {{# testcondition2}} \ n & lt; H1 & gt; Ghi & lt; / H1> \ N {{/ if}} \ n & lt; H1 & gt; Xyz & lt; / H1> \ N   

You can see that if the first condition is false, then the code without the left branch is:

   \ N \ n {{#if testcondition2}} \ n & lt; H1 & gt; Ghi & lt; / H1> \ N {{/ if}} \ n & lt; H1 & gt; Xyz & lt; / H1> \ N   

which gives you two new lines in one line.

No comments:

Post a Comment