eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.35k stars 60 forks source link

Newlines are lost when proceeded by a closing template tag #285

Closed kevinkace closed 2 months ago

kevinkace commented 2 months ago

Describe the bug If a template tag is the last part of a line, then the adjacent newline character is lost.

To Reproduce Steps to reproduce the behavior: If a template tag is the last part of a line, then the adjacent newline character is lost.

Steps to reproduce the behavior:

  1. create a template with a line that ends in a closing tag:
    line before data
    <%= it.data %>
    line after data
  2. render template with data

Expected behavior Newline is preserved

Screenshots image

Package & Environment Details Node 20.11.1

Additional context https://replit.com/@kevinkace/eta-tests

nebrelbug commented 2 months ago

This is expected behavior! If you want to change this, you can change autoTrim in the config from [false, 'nl'] (default) to [false, false].