简体   繁体   中英

Backbone JST Template, How to Render Rails Partials

A couple of select elements in my JST Template rely on the db to populate choices. Can I pull a rails partial into my template? What is the best way to do this?

For example a partial like this:

_font_faces.html.haml

.font_face
  = select("font", "style", Font.all.collect {|f| [ f.name, f.id ] })

The answer to this question is, you don't want to put that kind of logic into your view anyways. There should be a separate backbone collection made, a font collection, not a call to the db in the view.

If you name something like choices.jst.eco.haml the asset pipeline will compile the file going backwards from the file extension. So, the HAML compiler will run first, then the ECO compiler, then the JST gem will throw all that compiled code into the JST object that you can reference in your view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM