Michael Baudino
Michael Baudino

Reputation: 173

Handlebars templates in HAML using Ember.js

I'm looking for a way to write my Handlebars templates using HAML, in a Ember.js application embedded in a Rails 3.2 project.

Handlebars is 1.0.rc.1, require'd from ember-rails gem 0.7.0
Ember is 1.0.pre-90-g60e3c05

Anyway, my template now looks like that :

<div id="container">
  This is my test
</div>

I'd like it to be like this :

#container
  This is my test

BTW, I'v seen James Harton's Hamlbars but I could not figure out how to make it work. It kept outputing Ember.TEMPLATES["templates/choose_resort"] = Ember.Handlebars.compile("This is my test"); instead of the intended :

<div id="container">
  This is my test
</div>

(even the div block is missing in the what-seems-to-be-uncompiled-code returned)

Any hint would be greatly appreciated. Thanks in advance.

Upvotes: 9

Views: 4897

Answers (3)

kiwiupover
kiwiupover

Reputation: 1780

There is a github project called Hamlbars. It looks like a great project I have not used it in a project yet but it looks promising.

this:

= hb 'App.widgetController.title'

will render:

{{App.widgetController.title}}

and this:

%ul.authors
  = hb 'each authors' do
  %li<
    = succeed ',' do
      = hb 'lastName'
      = hb 'firstName'

will render to

<ul class="authors">
  {{#each authors}}
    <li>{{lastName}}, {{firstName}}</li>
  {{/each}}
</ul>

I took a look I'm sure it is just what you are looking for.

Cheers

Upvotes: 2

Alex Matchneer
Alex Matchneer

Reputation: 3309

Try the new Emblem.js. It's closer to Slim than HAML but cleanest you'll get if you're fond of indented templating languages and Ember.js.

And it is the one recommended by Ember.js guide

Upvotes: 5

freemanoid
freemanoid

Reputation: 14770

How to install hamlbars in three steps: guide

Upvotes: 2

Related Questions