Pergunta

I'm new to Velocity, so I have a template with lot of boolean value. And what I want is to define just once a condition who replace every "true" by "yes" and every "false" by "no". Cause I don't want to write the condition for each of my variable.

There is a way to do that ? in the begining of my template for example.

Foi útil?

Solução

You can define a macro:

#macro( formatboolean $booleanvalue )
  #if ( $booleanvalue ) yes #else no #end
#end

and use it in your template:

#formatboolean ( $myboolean )
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top