我想在我的新项目中将所有html.erb文件转换为.slim。我错过了表单中的最后一个 - 选择输入。
form.html.erb看起来
<%= form_for @user do |f| %>
<%= f.hidden_field :document_id, value: @doc.id %>
<%= f.label :Obor %>
<%= select(:user, :job, [
["Choose work"],
["Admin"],
["Other"]
], {disabled: "Choose work", selected: "Choose work"}, class: "form") %>
<%= f.button "Submit" %>
<% end%>
一切都按我想要的方式运作。我试图以这种方式在.slim中制作它:
= form_for @user do |f|
= f.hidden_field :document_id, value: @doc.id
= f.label :Obor
= select(:user, :job, [
["Choose work"],
["Admin"],
["Other"]
], {disabled: "Choose work", selected: "Choose work"}, class: "form")
= f.button "Submit"
它不适用于错误:未知行指示符 - &gt;
new.slim, Line xx, Column xx
["Choose work"]
如何将select从html.erb转换为.slim?谢谢。
编辑 - 答案:感谢里卡多提到的erb_to_slim gem,我找到了解决方案。我只是错过了选择器每一行的轨道指示器。答案是:
= form_for @user do |f|
= f.hidden_field :document_id, value: @doc.id
= f.label :Obor
= select(:user, :job, [
= ["Choose work"],
= ["Admin"],
= ["Other"]
= ], {disabled: "Choose work", selected: "Choose work"}, class: "form")
= f.button "Submit"
答案 0 :(得分:2)
您是否尝试使用gem erb_to_slim?
在您的终端类型中:
gem install erb_to_slim
在项目文件夹中,使用:
erb_to_slim
所有erb文件都将转换为slim文件,erb文件将被重命名。
也许这会有所帮助。