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

That's just a bad system, not inherent to templating systems in general. Django (python) got it right: All variables that go into a template are escaped by default, you have to go out of your way to tell it not to do that.

String formatting on the other hand, yeah, no good way like that in a language not designed for it.

Not sure which you and GP meant by "string templates".



Unless the template is aware of the semantics of the html being output, it can’t always know how to escape. E.g. the escaping rules are different for a css variable embedded in an inline style compared to using it in a javascript context.

That is what made JSX so neat.


and modern templating systems do! https://pkg.go.dev/html/template

> This package understands HTML, CSS, JavaScript, and URIs.

No JSX needed.




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

Search: