在erb中打印数据
如何在 erb 中打印数据(通常是 html)?有时不可能在控制器中完成所有操作,例如
在结构较大的红色 div 中打印“你很有趣”,
我
在结构简单的蓝色 div 中打印“你很搞笑”
无法将它们存储在变量中在控制器 n 中,然后在 erb 中打印它
,并且 <%= %>标签不适用于多行代码,它们只打印块中最后一行的最后结果。还有其他方法吗?
How can I print data, usually html, in erb? Sometimes it is just impossible to do everything in the controller, like so
print "you are funny" in a red div, with a big structure
and
print "you are hilarious" in a blue div with simple structure
I cannot store them in a variable in the controller n then print it in erb
and the <%= %> tags dont work over multiple lines of code, they only print the last result of the last line in block. Are there any other methods?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在新的 Rails 应用程序中输入 script/generatescaffold Post name:string title:string content:text 并研究生成的 .html.erb 文件。
或者,更好的是,从一些 rails 教程开始。
Type
script/generate scaffold Post name:string title:string content:text
in new rails app and study generated .html.erb files.Or, better yet, start with some rails tutorial.