php - What's the point of javascript templating engines? -


I know people generally answer, but I need a solid example of why they are necessary.

I'm getting the latest impressions (mostly from underscore .js) is that it creates code and php, such as you & lt; %%> like?> In PHP

The idea is to create less spaghetti for my code and there is a clear difference between presentation and logic. This is what everyone says, but I'm not sure why this warrants the need for a templating engine.

Why can not you just do this in pure JavaScript? You have only one function that takes data as a logic and you can have javascript syntax without searching for a new language, which seems ridiculous. For example, you can just do this:

  populateTable (obj) {$ ('#models'). Html ('& lt; h2 & gt;' + obj.title + '& lt; / h2 & gt;' + & lt; ul & gt; ...  & gt;}  

This sounds good to me, it's a function that you are dedicated to presenting in the table using some model data. Do we need to invent new syntax?

One of the reasons for me is that I like to write:

  Lt; div class = "entry"> 

{{title}}

{{body}} & lt ; /

  var createEntryTemplate = function (obj) {w '' 'L' div 
Title + '& lt; / h1 & gt;' + '& lt; div class = "body" & gt; + + obj.body +'
& # 39; & # 39; + & lt; / div & The second method is more error prone - if it's not for you, maybe for someone else. There is not enough programming experience and it needs to go to HTML and change its important part

Oh nonsense ...


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -