Hi!
There’re so many template engines for both frontend and backend. But they all lack of incorporating with each other. Templates written for backend rendering cannot be reused for frontend and vise versa.
For instance, how can i implement a template written in Smarty on the client-side? Those templates all depend on a specific engine and are therefore not reusable.
Why are they all so popular? (Twig, Smarty, Plates, Jade, Haml, Mustache, Handlebars, Dust, Ctemplate, etc, etc, etc)
Here is a simple example. Let’s assume this template which will be evaluated server-side:
<div>Hello {{name}}</div>
After rendering i get something like this: <div>Hello Bill</div>
Now there’s is no way i can reference back to ‘name’ in the frontend.
Why don’t we simply write templates using nothing but html. Maybe like so?
<div>Hello <span></span></div>
Are there already template engines like this for frontend and backend, which simply allows to bind or link data to an element or attribute.
The closest i could find which does about what i have in mind is pure.js It was already written back in 2008 (although there’re some points i don’t ike about it). But for server-side?
Here are my criteria for such a template engine:
- No inline logic. Separation between representation and logic
- Templates must be written in pure html (no embedded complex language such as Mustache) and can be implemented in frontend and backend.
- (optional) Collaboration between frontend and backend by both following the same api.
Please let me know what you think, many thanks!