danhere danhere - 2 months ago 11
Javascript Question

Outputting a class with Rivets.js?

I thought this would be easier unless I'm missing something but I can't figure out how to output a piece of my data as a class.

<div class="partner-type" rv-class="partner.partner-type"></div>


doesn't work. It should say the value in that property "technology" or "service". Is there anyway to do string interpolation or something? Data attrs?

Answer

I ended up using something like

rv-class-ineededthisclass="partner.partner_type | isNotEqual 'premier'"

Btw, this library is great for rivetsjs: https://github.com/matthieuriolo/rivetsjs-stdlib