xnjiang
xnjiang

Reputation: 597

emberjs analogue of rails partial

I am porting my rails view to emberjs. It seems that there are view and outlet helper for template separation. Since outlet is for state change, I am planning to use view helper to mimic rails partial. Am I right?

Upvotes: 1

Views: 1525

Answers (1)

Alex Matchneer
Alex Matchneer

Reputation: 3309

Declaring views just to use them as partials is probably overkill. What might suit you best is the {{template}} helper in handlebars. If you've got a precompiled template in your Ember.TEMPLATES hash, you can do {{template "sometemplate"}} to inject that template, similar to a rails partial.

There's also a syntax particularly for partials in vanilla Handlebars, but I don't think it's well supported in Emberland and I never see anyone use it, and template does the same thing afaik.

Update 1/19/2013

There is now a {{partial}} helper you can use to insert insert template partials, whose filename's (and therefore Ember.TEMPLATES names) must begin with an underscore. Thanks to @brg for the heads up.

Upvotes: 7

Related Questions