【发布时间】:2014-10-24 19:50:33
【问题描述】:
有没有办法将_header.slim 和_footer.slim 放在单独的文件中并将它们注入到其他(主)slim 文件中?
我正在构建这样的模板:
def slim(template, context = nil)
Slim::Template.new { template }.render(context)
end
def template(name)
File.read(Notifications.root.join "notifications/templates/#{name}.slim")
end
当我注入 slim('_header.slim') 或仅注入 template('_header.slim') 时,它会在我的主布局中呈现为纯文本。
有什么办法吗?
【问题讨论】:
-
您可以尝试使用
html_safe来查看html 输出而不是计划文本。
标签: ruby-on-rails ruby templates slim-lang