I am trying to use a named route with {{id}} as one of the parameters, allowing processed content to consume Handlebars. url_for speeds up the parameter, so the resulting URL contains %7B%7Bid%7D%7D . I tried adding :escape => false to the call, but it has no effect.
routes.rb
resources :rants, :except => [:show] do post '/votes/:vote', :controller => 'votes', :action => 'create', :as => 'vote' end
index.haml
%script{:id => 'vote_template', :type => 'text/x-handlebars-template'} .votes = link_to 'up', rant_vote_path(:rant_id => '{{id}}', :vote => 'up') %span {{votes}} = link_to 'down', rant_vote_path(:rant_id => '{{id}}', :vote => 'down')
application.js
var vote_template = Handlebars.compile($('#vote_template').html());
Output
<script id="vote_template" type="text/x-handlebars-template"> <div class='votes'> <a href="/rants/%7B%7Bid%7D%7D/votes/up">up</a> <span>{{votes}}</span> <a href="/rants/%7B%7Bid%7D%7D/votes/down">down</a> </div> </script>
I simplified the example for readability, but the question remains the same; is there any way to use a named route with {{ }} as a parameter? I understand that I can just do link_to 'up', '/rants/{{id}}/votes/up' , so please do not report this as an answer.
source share