在erb中打印数据

发布于 2024-09-14 20:51:01 字数 225 浏览 6 评论 0原文

如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我偏爱纯白色 2024-09-21 20:51:01

在新的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文