I am using velocity in my project, and I have a list with icon for each item in list, but I want to set de class icon according what come from my database, to make my menu dynamic.
<li>
#foreach($item in $navegacao)
<a href="javascript:void(0);" class="with_sub"><img src="#link("resources/theme/mango/img/icons/packs/fugue/16x16/application-form.png")" alt="" height="16" width="16">$item.nome</a>
<ul class="sub" style="display: none;">
#foreach($nav in $item.navegacoes)
<li class="with-icon"><a href="ui_grid.html"><span class="icon icon-th"></span>$nav.nome</a></li>
#end
</ul>
#end
</li>
I have this code <span class="icon icon-th"></span>, but instead of icon icon th, I want to set a new class, I tried <span class=$nav.classIcon></span> but its not working. My objects navegacao and item.navegacoes is coming right in my session.
Your
classattribute is missing the enclosing quotes; since you’re setting multiple classes, these are required (and should really be there in any case).