Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double New line #2

Open
mrosalesdiaz opened this issue Jun 12, 2013 · 2 comments
Open

Double New line #2

mrosalesdiaz opened this issue Jun 12, 2013 · 2 comments

Comments

@mrosalesdiaz
Copy link

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.

@cramforce
Copy link
Owner

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

@mrosalesdiaz
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants