holy grail of templating engines in javascript

Hamzeen Hameem

--

these days when you scratch the surface, you will land on numerous javascript templating engines. Apart from infamous Handlebars & Mustache, there are many other libraries out in the wild — ejs, jade, etc.

When you strip down all the fancy features each of them provide, you might realise at their heart, they all let you pass in variables wrapped in double curly braces {{temperature}} which would then get replaced by its real content.

In vanilla javascript you can form string literals like so:

`string text ${expression} string text`

Sticking to the subject of this post, here is how you could write your own function to interpolate variables wrapped in double curly braces:

Reference:

--

--

No responses yet

Write a response