新手问题 想问下 HTML 如何转换为 erb 代码

nicetyler · May 09, 2017 · Last by torvaldsdb replied at May 10, 2017 · 2356 hits
<a class="btn btn-primary pull-right" href="#">Sign up
        <span class="glyphicon glyphicon-circle-arrow-right-right"></span>
</a>

上面代码里面嵌入了一个标签如何转换成 erb

link_to + content_tag

Reply to alexneverpo

可以写下完整的代码,我加了 content_tag,但是写了几次都是错误

Reply to nicetyler

try harder😁

Reply to hong_xin

报错总是说我没什么变量,你们有写过得的代码码能发来看下吗

Reply to rina

怎么转不了啊,我在上面输入 html 代码没转过来

Reply to nicetyler

这个链接是 haml to erb 的,你要先把 html to haml. http://htmltohaml.com/. 另外这只是个思路。你自己也要想想啊。

谁会写的帮我写下吧,有好几个这样代码写了一下午了,<%= t('support_center') %> 还有这样的,实在是不会写有会写的帮忙写下吧万分感谢

<%= link_to "#",class:"btn btn-primary pull-right" do %>
  <%= 'Sign up' %>
    <%= content_tag(:span,'',class:"glyphicon glyphicon-circle-arrow-right-right") %>
<% end %>

像这种干嘛非得用 Rails 的写法,直接用原生的写就好了

没有可变的部分为什么要插 erb 标签?

Reply to Rei

我写原生的话跳转不了我是想写成点击然后弹出下拉菜单,并且跳转到其他页面,那个 a 标记里面的 href 怎么用不了路由

Reply to aoreki

谢了照你这样写成功了

Reply to aoreki

content_tag 新项目都改用这种写法。

nicetyler closed this topic. 10 May 17:53
You need to Sign in before reply, if you don't have an account, please Sign up first.