Templates are a very simple way to structure your code. With them you basically add
html snippets as a script tag to your dom. Then you can reference them which creates
much cleaner code.
But adding them to your html in a script tag has some drawbacks. First we’d like to minimize the size of your html.
Second, we’re missing syntax highlighting in the IDE. And third, wouldn’t it be great if it was lazy loaded?
“But darling that’s three wishes altogether! You know that’s not possible!”
“But yes, it is possible!” Just use this little
snippet:
With this little snippet you can load any template lazily:
The template itself is a regular html snippet, so any decent IDE will give you
syntax highlighting and code completion. Your main html file is clean and small
and the script is loaded lazily.
“KinderSurprise three wishes at once” - from DukeScript!
P.s.: This is just one (very simple) way of doing it. Stay tuned for more feature rich alternatives.