Sebastien
Sebastien

Reputation: 6660

Make a link with inner HTML using Haml and rails 3 router

I created this html :

%a.btn.btn-large.btn-primary.getting-started
    %i.icon-arrow-right.icon-white
    = t('header.getting-started')

Now, i want to specify the href of my a tag using my rails router. How can i do that? I tried that :

%a.btn.btn-large.btn-primary.getting-started{:href => =url_for(pdf_path)}
    %i.icon-arrow-right.icon-white
    = t('header.getting-started')

But it fails. And using link_to, i don't know how to write inner html into the a tag.

Upvotes: 1

Views: 653

Answers (1)

dennis
dennis

Reputation: 2020

I would suggest using the link_to syntax like this:

= link_to target_path(), class: 'foo' do
  %i.icon-arrow-right.icon-white
  = t('header.getting-started')

This will actually route to the target path and will assign the link body to the attributes defined under do

Have fun

Upvotes: 3

Related Questions