Ember.js compatibility with mustache libraries

I am currently developing a PHP site that I plan to use with Mustache PHP so that I can use the same mustache template files with my PHP rendering, as well as with my javascript (ajax driven) updates. After searching around, I could not find the equivalent handlebars.js library for PHP, although I would prefer to use rudders for everything.

I decide whether to use Ember.js or Backbone.js. I know that Ember uses descriptors, and these descriptors use syntax and functions that are not in the mustache.js file on which it is based. I also understand that handlebars.js works great with mustache templates.

I tend to Ember, and I am ready to develop and update Mustache PHP to work with Handlebars.js, if necessary.

But first of all, will Ember.js work with direct mustache patterns? Or does using Ember correctly also involve using template functions supported only by handles?

If I need to unlock the PHP library, what are the main steering functions that I will experience first to add?

Thanks in advance, this will really help me decide if I should use Ember.js.

+4
source share
2 answers

I did not need to use Ember, but noticed that shortly after I posted this question, someone else started the Handle Parsing project in PHP and this library is a different approach . These libraries were the solution I was looking for, since there were so many potential complications when processing rudder templates using only the mustache visualization tool.

0
source

Handlebar.js adds some "helpers" to the "Mustache" syntax (.php / .js) ... But they are absolutely useless, since Mustache is all very good:

{{#each xyz}}...{{/each}} is the same as {{#xyz}}...{{/xyz}} in Mustache. {{#if xyz}}...{{/if}} is the same as {{#xyz}}...{{/xyz}} in Mustache. {{#with xyz}}...{{/with}} is the same as {{#xyz}}...{{/xyz}} in Mustache. 

On the contrary:

 {{#unless xyz}}...{{/unless}} is the same as {{^xyz}}...{{/xyz}} in Mustache. 

Ember.js is very similar to handlebar.js, while Backbone.js seems to add a lot of logic to the logical-agnostic Mustache-view-rendering of some output.

I use Mustache (php) on some small and large sites. Ajax calls the result in Mustache populating the peice html, and jQuery replaces some dom elements with the result. It works like a charm.

Me: do not add logic to Mustache, just remove the logic from Handlebar.js (I think that it will work without these "helpers".)

+1
source

Source: https://habr.com/ru/post/1435610/


All Articles