Is it a good idea to mix Mustache / Handlebars templates with HAML?

I would like to know whether to mix Mustache or Handlebars templates with HAML. If so, what are the advantages and disadvantages. Why am I asking about this? I saw the Brommers mix patterns. Thanks.

+4
source share
1 answer

I create mustache templates with HAML without any problems.

My HAML looks something like this:

.template.shop .foreground .header .header-logo .shop-description .table-frame %a.close-button{:href=>"#"} Close %table %tr %td.shop-images %td.shop-details %p.popup-headline.fix-width {{addr_name}} %p {{addr_street}} {{addr_number}} %br/ {{addr_zip}} {{addr_city}} / {{#hasSchedule}} %p.popup-headline \Öffnungszeiten %table.shop-schedule / {{#sched_mo}} %tr %td Mo: %td {{sched_mo}} / {{/sched_mo}} ... Rest of Table omitted 

It works like a charm. It displays as HTML on the server, which I am extracting from the page using jQuery on the client. Then I take the HTML template and process it with a mustache.

Because of this, you sometimes need to be careful where the mustache tags appear . For the browser, they are just text, so they are not valid between the rows of the table, for example. In this case, put them in the HTML comments, as in my example.

You can also avoid the generated HTML / Mustache on the server. This was not possible in my case because I wanted to create the generated part of my HTML template to simplify the styling.

+3
source

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


All Articles