3 ms·
The linked code doesn't show the full value of this technique, since its straightforward HTML that's coming out. Now what happens if you want a collection of l
by blacktriangle 6y ago
The linked code doesn't show the full value of this technique, since its straightforward HTML that's coming out.
Now what happens if you want a collection of list items generated by looping over an array?
Assign classes based on some logical conditional?
Conditional rendering?
These are problems everybody has and every template language tries to solve with their own custom syntax.
The point of this method is that rather than create some half-assed template language, you just write Javascript code that acts on and generates a data structure that can then be converted into HTML.