totaljs / Tangular

A simple JavaScript template engine like Angular.js for websites or node.js
MIT License
61 stars 21 forks source link

Redundant empty line generated when "if" condition not filled #9

Closed Darmody closed 7 years ago

petersirka commented 7 years ago

Can you write a simple demo?

Darmody commented 7 years ago
<div> A </div>
 {{if false }}
   do some things
 {{fi}}
<div> B </div>

it will output to

  <div> A </div>
                                       // here is an empty line
                                       // here is an empty line
                                       // here is an empty line
  <div> B </div>
petersirka commented 7 years ago

Yes, because:

<div> A </div>\n
 {{if false }}
   do some things
 {{fi}}\n
<div> B </div>

but you can write it as:

<div> A </div> {{if false }}
   do some things
 {{fi}}<div> B </div>

Tangular doesn't minify the output. I use Tangular (sometimes) in <pre tag and here are very important white spaces, so therefore....

Darmody commented 7 years ago

But {{if false}} don't mean anything in output. I think it should not take up a line.

And it is a different thing from minify.

petersirka commented 7 years ago

I'll look into it this weekend.

Darmody commented 7 years ago

@petersirka That's cool!

petersirka commented 7 years ago

I have fixed it. Try to install latest version from NPM.