Create a partial just like you would with erb, prefixing the name with an underscore.
The template will have access to all normal rails helper methods and any instance variables that were set in the controller. If you need more than this an optional view class can be included, it should have the same name as the partial, but without the underscore.
app/views/posts/post_list_view.rb module Posts class PostListView < Poirot::View def foo "bar" end def post_link post_path(post) end end end
The view class has access to all the normal Rails helpers and access to the controller instance variables, e.g @post becomes the method post.
//= require posts/_post_list MustacheTemplate['posts/_post_list']
If you are using rails 3 then you can run the
<%= template_include_tag 'post_list' %>
This will return the contents of the
post_list template wrapped in a jQuery object, ready for inserting into the dom. If you have data to pass to the template then you can pass it as the argument to the function, e.g.
- Rails >3.0.0
An example app using Poirot