How can I output raw html from this Rails route / helpers?

I am trying to use the following bit of code to create a link on my page

%h2= link_to '{{ label }}', product_path('{{ id }}'.html_safe)

This is actually part of a large block of HTML that will serve as a javascript template, and I will analyze later with help Underscore.jsto fill in placeholders {{ id }}and {{ label }}. So I would like the rails to output something to my HTML, for example

/ products / {{id}}

However, he continues to avoid spaces and braces and giving me

<a href="/products/%7B%7B%20id%20%7D%7D">{{ label }}</a>

So url_helper eludes my line, although I don't want this. How can I make him not do this?

I tried

%h2= link_to '{{ label }}', product_path('{{ id }}'.html_safe)
%h2= link_to '{{ label }}', product_path(raw '{{ id }}')
%h2= link_to '{{ label }}', raw(product_path('{{ id }}'))

and

%h2=raw( link_to '{{ label }}', product_path('{{ id }}'.html_safe))

But none of them work

EDIT:

Another way to play with this is with the rails console,

include ActionController::UrlWriter

ruby-1.9.2-p0 :010 > product_path '{{ id }}'.html_safe
 => "/products/%7B%7B%20id%20%7D%7D" 

Any help appreciated ... thanks

thank

+5
1

CGI::unescape(product_path('{{ id }}')? ( require 'cgi', .)

, Ruby 1.9.2, , , , .

+6

All Articles