3 ms·
Twig does not require you to write escape so you can have to write just {{ var }} That is a big difference because beginners always forget about escaping.
by codedokode 10y ago
Twig does not require you to write escape so you can have to write just
{{ var }}
That is a big difference because beginners always forget about escaping.
> Nevertheless, I used DOM/libxml on the server side in PHP/C,
There used to be XSLT templates but they don't seem to be popular now. Constructing DOM trees in the code without using templates is probably inconvinient and produces bloated code.
- megous 10y agoNot that much bloated. And it can be quite readable if done well. You also don't need to learn peculiarities of for loops or macro language in a given templating system. The host language is it's own macro language with all the features you already know, and not limited to whatever template language authors decided to implement. Beginners also forget about balancing HTML tags, which is quite unpleasant experience when creating and changing more complicated templates with loops, conditions, etc. You can also do post-processing on the constructed DOM, even during construction. Bloated code only happens if the programmer fails to structure the code into nicely re-usable functions. Anyway, it seems to be quite popular right now with all the react hype - React.createElement is such a helper function to help construct DOM tree. It's pretty much the same concept on the server side. Except you don't need to care about DOM diffing, because server has no persistent DOM.