BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.
http://www.jsviews.com
MIT License
2.67k stars 339 forks source link

JSRender strips multiple white spaces from input #356

Closed mattrout92 closed 4 years ago

mattrout92 commented 4 years ago

When I try to render a template with multiple white spaces in the input, it strips the number of spaces down to just one. It would be nice to be able to configure stopping this from happening!

E.g

Hello (4 space characters) World renders to Hello World

BorisMoore commented 4 years ago

If the template has multiple adjacent white spaces, that is preserved in the output:

<script id="personTmpl" type="text/x-jsrender">Hello [4 spaces] World</script>

If you have it in data, {label: "Hello [4spaces] World"} then {{:label}} will also preserve the spaces in the output.

So I'm not sure what your scenario is where the white space is getting reduced to one space. Can you provide a sample?

BorisMoore commented 4 years ago

@mattrout92: I didnt hear back from you. It's possible you thought JsRender was stripping white spaces, when in fact you were simply seeing the normal HTML rendering which will display

"a  b"

as if it was

"a b"

(That behavior is part of HTML and is nothing to do with JsRender.)

I will close this issue

BorisMoore commented 4 years ago

See also https://github.com/BorisMoore/jsrender/issues/358#issuecomment-624911090