You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@locus.apache.org on 2000/11/20 00:29:46 UTC

cvs commit: jakarta-velocity/test/templates velocimacro.vm

geirm       00/11/19 15:29:45

  Added:       test/templates velocimacro.vm
  Log:
  Example template to use both a global library VM as well as define inline and use.
  
  Revision  Changes    Path
  1.1                  jakarta-velocity/test/templates/velocimacro.vm
  
  Index: velocimacro.vm
  ===================================================================
  #**
  
  @test velocimacro.vm
  
  This template is used for Velocity regression testing.
  If you alter this template make sure you change the
  corresponding comparison file so that the regression 
  test doesn't fail incorrectly.
  
  *#
  ## inline VM : shows how a tablerow might be generated
  
  #macro( tablerow  $array $color )
  #foreach( $element in $array )
     <tr><tdi bgcolor=$color>$element</td></tr>
  #end
  #end
  
  Now, use the \#quietnull example from the global library VM_global_library.vm : 
  Now, there should be nothing in the brackets : >#quietnull($nada)<
  
  #set $foo = "hello!"
  Where there should be something here : >#quietnull($foo)<
  
  #set $arr = ["$10.24","$15.32","$12.15"]
  #set $col = "blue"
  
  <table>
  #tablerow( $arr $col)
  </table>
  
  
  Further tests.  The following VMs and non-VM should be properly escaped :
  \#tablerow
  \#quietnull
  \#notavm
  >\\#quietnull($nada)<
  
  Now try to define a new quietnull VM :
  #macro( quietnull $a )
  	QuietNull : $a
  #end
  
  It should have been rejected, as the default is to not let inlines override existing, and there
  should be a message in velocity.log.
  Therefore it should still function normally :
  >#quietnull($foo)<
  >#quietnull($nada)<
  
  
  - Another fine Velocity Production -