Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It would become unusable for general-purpose text templating[0], and would either break interspersing dynamic text ("this is {{ name }}" with name=Bob would be rendered as "this isBob") within static text or would need a semantic understanding of HTML.

And even then the presence or absence of whitespace in HTML does have rendering impacts (though I don't remember one offhand — aside from linebreaks — it's been a long time since I last hit one), so the template author must be able to control it and importantly to keep whitespace present between static and dynamic items.

[0] html/template is a relatively thin layer over text/template with built-in XSS security where the original does "raw" output by default



I just think that a simpler solution would be to always ignore the first line break after the range begin and end tags. I can't really see the case where that would cause an issue, if you REALLY do need the "extra" line break just put it inside the range.

Whitespaces shouldn't be touched, just parse them though and don't process them.

That would make the templates look more like those of Django and Jinja2, which most seem comfortable with.


Funny that you mention Jinja.

This is actually a feature that's been in Jinja forever that I've always wanted in Go's text/template

http://jinja.pocoo.org/docs/dev/templates/#whitespace-contro...


> Whitespaces shouldn't be touched, just parse them though and don't process them.

That's what html/template does by default, the point of the addition is this can be inconvenient as you may want whitespace for source readability but can't have whitespace in the output.

> That would make the templates look more like those of Django and Jinja2, which most seem comfortable with.

The behaviour outlined here is the same as jinja's: output text nodes as-is by default (whitespace and all), specify `-` to trim whitespace on the corresponding side of a template item.


Whitespace inserts a text node in the DOM. I think.


Whitespace is text, yes?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: