tosenzzz / trimpath

Automatically exported from code.google.com/p/trimpath
0 stars 0 forks source link

Error when a block is followed by multiple newlines #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. TrimPath.parseTemplate("{if true} {/if}\n\n\n stuff")

What is the expected output? What do you see instead?
Should return a parsed template, instead throws an error (SyntaxError:
unterminated string literal"

What version of the product are you using? On what operating system?
1.0.38, Firefox 2.0/WIN

Please provide any additional information below.
This appears to be a problem in the emitSectionText() function, because the
functions where it replaces newlines with the \n escape sequence only
replaces the first newline. It can be fixed by changing the following line:

var s = text.substring(0, nlPrefix).replace("\n", '\\n'); // A macro IE fix
from BJessen.

to:

var s = text.substring(0, nlPrefix).replace(/\n/g, '\\n'); // A macro IE
fix from BJessen.

Original issue reported on code.google.com by breischl@gmail.com on 23 Apr 2008 at 7:53

GoogleCodeExporter commented 8 years ago
If you do have multiple newlines at the end of a trimpath block (for example,
your trimpath is generated), one way to work around this bug is by adding 
(at least one) space characters to the end of the trimpath block.

i.e.

  |if some_condition|    
      $|show_value_a|
  |else|
      $|show_value_b|
  |/if| <!-- add blank spaces after the if -->

Original comment by francis....@gmail.com on 13 Mar 2009 at 12:17