Insert ruby in html class=“ ” property

痞子三分冷 提交于 2019-12-12 09:22:45

问题


This is probably really stupid but I've spent the last 2 hours trying to figure out how to do this with no luck at all.

Basically I need my html page to do the following:

<div class="circleElement">
...
</div>

But I need to add more classes to that div class with ruby, the classes are coming in from a text field in my database.

I tried inserting ruby like:

<div class="circleElement"+ <%= u.tag %> >...</div>

And many different variations of this line with no luck at all :(

I should add that u.tag holds exactly this string> "activeTag classicTag".... so it should append with no problems but it's not doing it!


回答1:


<div class="circleElement <%= u.tag %>" >...</div>

should work.



来源:https://stackoverflow.com/questions/17820145/insert-ruby-in-html-class-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!