CodeMirror: Velocity mode

1
## Velocity Code Demo
2
#*
3
   based on PL/SQL mode by Peter Raganitsch, adapted to Velocity by Steve O'Hara ( http://www.pivotal-solutions.co.uk )
4
   August 2011
5
*#
6
 
7
#*
8
   This is a multiline comment.
9
   This is the second line
10
*#
11
 
12
#[[ hello steve
13
   This has invalid syntax that would normally need "poor man's escaping" like:
14
 
15
   #define()
16
 
17
   ${blah
18
]]#
19
 
20
#include( "disclaimer.txt" "opinion.txt" )
21
#include( $foo $bar )
22
 
23
#parse( "lecorbusier.vm" )
24
#parse( $foo )
25
 
26
#evaluate( 'string with VTL #if(true)will be displayed#end' )
27
 
28
#define( $hello ) Hello $who #end #set( $who = "World!") $hello ## displays Hello World!
29
 
30
#foreach( $customer in $customerList )
31
 
32
    $foreach.count $customer.Name
33
 
34
    #if( $foo == ${bar})
35
        it's true!
36
        #break
37
    #{else}
38
        it's not!
39
        #stop
40
    #end
41
 
42
    #if ($foreach.parent.hasNext)
43
        $velocityCount
44
    #end
45
#end
46
 
47
$someObject.getValues("this is a string split
48
        across lines")
49
 
50
#macro( tablerows $color $somelist )
51
    #foreach( $something in $somelist )
52
        <tr><td bgcolor=$color>$something</td></tr>
53
    #end
54
#end
55
 
56
#tablerows("red" ["dadsdf","dsa"])
57
 
58
   Variable reference: #set( $monkey = $bill )
59
   String literal: #set( $monkey.Friend = 'monica' )
60
   Property reference: #set( $monkey.Blame = $whitehouse.Leak )
61
   Method reference: #set( $monkey.Plan = $spindoctor.weave($web) )
62
   Number literal: #set( $monkey.Number = 123 )
63
   Range operator: #set( $monkey.Numbers = [1..3] )
64
   Object list: #set( $monkey.Say = ["Not", $my, "fault"] )
65
   Object map: #set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"})
66
 
67
The RHS can also be a simple arithmetic expression, such as:
68
Addition: #set( $value = $foo + 1 )
69
   Subtraction: #set( $value = $bar - 1 )
70
   Multiplication: #set( $value = $foo * $bar )
71
   Division: #set( $value = $foo / $bar )
72
   Remainder: #set( $value = $foo % $bar )
73
 
74
 
 

MIME types defined: text/velocity.