简体   繁体   中英

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 . It says:

By default, content_for :thing appends whatever you put in your block to the previous value of :thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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