As far as i know, Templates are used to seperate presentation from Logic and it can be reused since it doesnot depond on any logic... Many suggested me to go for Handlebars.js for templating.(This is the first time i'm hearing this name).
I want to know What is meant by Logic-less template?
Thanks
Note: I have gone through this What's the advantage of Logic-less template (such as mustache)? question as well.. But i didnt get clear idea.
Handlebars is logic-less since you cannot execute JavaScript inside templates. You cannot write {{# if num==1}}
. Instead, you have to prepare a boolean in JS: var numIsOne = num==1;
, and the template should contain {{# if numIsOne }}
. That is what logic-less means.
The basic task of a template library is to provide a mechanism to fill some computed data into the more or less static template, like to fill in the name in "Hello, ${name}". Many template libraries, however, offer additional features, like if-then statements, loops, arbitrary code execution, and so on. This is the logic that logic-less templates try to avoid.
This means that logic-less template libraries just provide the basic functionality of filling in data into a template.
The reasons for using logic-less templates are given in the question you referenced, so I won't list them here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With