node-asyncEJS icon indicating copy to clipboard operation
node-asyncEJS copied to clipboard

Double New line

Open mrosalesdiaz opened this issue 12 years ago • 2 comments

I am using a template like this

html
  head
    title "Hello " <%= ctx.opts.layout_name %>
  body
    div

It generates double \n per each newline causing this output

html

  head

    title "Hello " ssss
  body

    div

Is this a bug or is there conf i missed.

My code:

te.template(view_template_file, function(template) {
      var params = {
        opts: opts
      };
      console.log({"params":params});
      var templateResponse = template(params);
      var file_content = [];
      templateResponse.addListener("body", function(chunk) {
        // chunk = chunk.replace(/\n\n/g,'\n') <-- to fix double \n
        console.debug(chunk); // [DEBUG] "html\n\n  head\n\n    title \"Hello \" "
        file_content.push(chunk);
      });
      templateResponse.addListener("complete", function() {
        console.debug(file_content);
        fs.writeFile(output_view_file, file_content.join(''), function(err) {
          if(err) throw err;
          console.log('It\'s saved!');
        });
        console.log("COMPLETE")
      });
    });

Thanks

Great work.

mrosalesdiaz avatar Jun 12 '13 23:06 mrosalesdiaz

This still works with a current version of node? I'm mildly surprised :)

cramforce avatar Jun 13 '13 07:06 cramforce

:o well I will check with current version. maybe I'll research the reason later. By now I will continue using that trick.

mrosalesdiaz avatar Jun 13 '13 15:06 mrosalesdiaz