简体   繁体   English

Rails <%provide%>多个变量

[英]Rails <%provide%> more than one variable

是否可以使用<%provide(:var,“ text)%>”方法为应用程序布局提供多个变量?如果是,语法是什么?

Not sure if it's possible to have two provide arguments, but there is a simple, if unsightly, solution: 不知道是否可以有两个提供参数,但是有一个简单的解决方案(如果难看):

<%provide(:var, "value)%>
<%provide(:var2, "value2")%>

If you want :var to have multiple values appended to it then, as per the explanation here , you should be using content_for . 如果要:var附加多个值,则按照此处的说明,应使用content_for It says: 它说:

By default, content_for :thing appends whatever you put in your block to the previous value of :thing. 默认情况下,content_for:thing会将您放入块中的所有内容附加到:thing的先前值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM