title: Velocity Template Engine: How to check if variable is set within macro via passed parameter
body: <p>I currently do have a working method which checks whether or not a variable is set.
  I do it like this</p>
  
  <pre><code>CHECKING EACH VARIABLE:
  #if($!{vh})
  vh instance found!&lt;br&gt;
  Classname: ${vh.class.name}&lt;br&gt;
  #end
  #if($!{su})
  su instance found!&lt;br&gt;
  Classname: ${su.class.name}&lt;br&gt;
  #end
  </code></pre>
  
  <p>This will currently print this:</p>
  
  <blockquote>
    <p>CHECKING EACH VARIABLE: 
    vh instance found!
    Classname: de.integration.commons.VelocityXPathHelper</p>
    
    <p>su instance found!
    Classname: de.integration.commons.StringUtils</p>
  </blockquote>
  
  <p>Hint: I injected theese variables into the context before.</p>
  
  <p>Since I do need to check for a lot of variables, and injected Variables differ sometimes, I created a macro who is supposed to do the same, combined with a loop over an array of strings who contains known injected variables like this:</p>
  
  <pre><code>#* Macro - checkIfVariableExists
  This macro checks if variable exists with the quit reference notation
  check http://velocity.apache.org/engine/devel/user-guide.html#quiet-reference-notation for more information *#
  #macro (checkIfVariableExists $variablename)
      #if($!{variablename})
          $variablename instanz found!&lt;br&gt;
          Classname: ${variablename.class.name}&lt;br&gt;
      #end
  #end
  
  RESULT FROM LOOP:
  #set( $toCheck = ["vh","su","anothervariable","...","....", "....."] )
  #foreach( $value in $toCheck )
      #checkIfVariableExists($value)
  #end
  </code></pre>
  
  <p>However, this will not work and result into this output:</p>
  
  <blockquote>
    <p>RESULT FROM LOOP: vh instanz found!
    Classname: java.lang.String
    su instanz found!
    Classname: java.lang.String</p>
  </blockquote>
  
  <p>How do I make this work? I do understand that value is a String, however I want to use the value of it as I did with my first approach. Any ideas? Im using velocity engine 1.7 and Im not able to change to a higher Version.</p>