Pergunta

I have this code

- value="true"

- if (value)
  p yes #if the condition is true I want to insert a glyphicon. (<i class="fa fa-check-circle"></i>)
- else
  p no

How to convert it into condition? <i class="fa fa-check-circle"></i> : <i class="fa fa-times-circle"></i>

But this is causing error!

Foi útil?

Solução

Your first code can simply be replaced with this:

= value ? "yes" : "no"

Any lines starting with = are evaluated, and the resulting return value is inserted into the document after a call to escape_html.

Because you explained in your comments that you actually want HTML code to be inserted, you'll have to do this:

== value ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-times-circle"></i>'
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top