简体   繁体   中英

add links into haml template

I implemented a template named "_list_two_lines"

%ul{:style=>"padding-top: 0; margin-top: 0"}
  - content.each do |element|
    %li{:style=>"font-family: Roboto, sans-serif; color: #333;font-weight: 300; font-size: 14px; "}
      ✓
      = render :partial => _text, :locals => {:inline =>true, :content => element[0] , :weight => bold_weight_email}
      %br
      = render :partial => _text, :locals => {:inline =>true, :content => element[1]}

Here I call it in the html.haml:

= render :partial => _list_two_lines, :locals => {:content => [["welcome to this forum","You need sign up first")]]}

How could I add a link to "sign up"? How could I achieve by modifying the template? So people will be redirect to another url clicking on sign up.

You could use the a tag:

%a{href: '/sign_up'}
  Sign up

Obviously replacing the href value with whatever link you have. If you are using haml inside rails you may (or should) use the built in link_to methods:

=link_to sign_up_path

or something like that.

(Also - it is considered bad style to have inline CSS like that. Move it to a CSS file and include it in your page header and add a class or id to the element you want to style.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM