Pregunta

Given the following macro:

#macro(sample $c1 $c2 $c3 $c4)
    ## do something with $c1..4
#end

My problem is that the input of #sample is very long, and everything would be more readable if I were to call it in the following manner

#sample(  $c1
          $c2
          $c3
          $c4 )

But this only grants a whitespace-error. Given that the only reason for me to use this macro is readability, I would like to make this somehow work. Any ideas?

Cheers!

¿Fue útil?

Solución

Are you able to do something like this:

#set( $options = [ "one",
                   "two",
                   "three",
                   "four" ] )
#macro(sample $options)
   #foreach( $opt in $options )
       ## do something with each $opt
   #end
#end

Another thing is trying to use comments (if I remember correctly). Maybe something like that:

#sample(  $c1 #*
       *# $c2 #*
       *# $c3 #*
       *# $c4 )

As I recall linebreaks where always buggy and wrapping them in comments would resolve those issues.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top