public
Created

render partial to jquery template

  • Download Gist
_partial.html.erb
HTML+ERB
1
this is a partial. <%= model.value %>
some_controller.rb
Ruby
1 2 3 4 5
class SomeController < ApplicationController
def show
@template_model = SomeModel.new(:value => "${value}")
end
end
use_partial_as_template.html.erb
HTML+ERB
1 2 3 4 5 6 7 8 9 10 11
<html>
<head>
<script id="some-template" type="x-jquery-tmpl">
<%= render :partial => "some/partial", :locals => {:model => @template_model} %>
</script>
 
<script language="javascript" type="text/javascript">
$("#some-template").tmpl({value: "this is some data"});
</script>
</head>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.