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

What's the benefit of parsing an HTML template, over just putting HTML string together with the data from the backend like "<p>your name: " + name + "</p>"?


In DOM you can add content gradually and asynchronously, which gets harder using HTML template.

Further you can read back previously added contents and make additional chagnes based on those. Like summing up table columns, or adding links to the first column values, or removing or fixing links based on authorization, to name a few.


Well XSS prevention for one.

Syntax aware template languages are a thing in the web space. They aren't the most popular but security people often like them because they lead to less mistakes. Some examples include soy, latte, and hack's XHP.




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

Search: