0

i want to print a string as a valuei tried following macro[2] and "set"[1] option too but still no luck;

[1]

#set( $faultVar = "#if($faultSeq)$faultSeq#{else}fault#end")

<resource faultVar="$faultVar">

This prints for else case like <resource faultVar=""> , but I expect <resource faultVar="fault">

[2]

#macro ( print_string_if_exist $field $default)
        #if($field && "$field" !="")
            $field
        #else
            $default
        #end
#end

This prints for edefault case like <resource faultVar=""> , but I expect <resource faultVar="fault">

How can i make my velocity teplate to print like; <resource faultVar="fault"> ?

Ratha
  • 9,434
  • 17
  • 85
  • 163
  • 1
    possible duplicate of [Escaping quotes in velocity template](http://stackoverflow.com/questions/19579748/escaping-quotes-in-velocity-template) – Xstian Sep 12 '14 at 14:55

1 Answers1

0

I corrected my macro to look like this:

#macro ( print_string_if_exist $field $default)
    #if($field && "$field" !="")
       "$field"
    #else
        "$default"
    #end
#end
winner_joiner
  • 12,173
  • 4
  • 36
  • 61
Ratha
  • 9,434
  • 17
  • 85
  • 163