4
<title>CodeMirror: Velocity mode</title>
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<script src="../../lib/codemirror.js"></script>
7
<script src="velocity.js"></script>
8
<link rel="stylesheet" href="../../theme/night.css">
9
<style>.CodeMirror {border: 1px solid black;}</style>
10
<link rel="stylesheet" href="../../doc/docs.css">
13
<h1>CodeMirror: Velocity mode</h1>
14
<form><textarea id="code" name="code">
17
based on PL/SQL mode by Peter Raganitsch, adapted to Velocity by Steve O'Hara ( http://www.pivotal-solutions.co.uk )
22
This is a multiline comment.
23
This is the second line
27
This has invalid syntax that would normally need "poor man's escaping" like:
34
#include( "disclaimer.txt" "opinion.txt" )
37
#parse( "lecorbusier.vm" )
40
#evaluate( 'string with VTL #if(true)will be displayed#end' )
42
#define( $hello ) Hello $who #end #set( $who = "World!") $hello ## displays Hello World!
44
#foreach( $customer in $customerList )
46
$foreach.count $customer.Name
56
#if ($foreach.parent.hasNext)
61
$someObject.getValues("this is a string split
64
#macro( tablerows $color $somelist )
65
#foreach( $something in $somelist )
66
<tr><td bgcolor=$color>$something</td></tr>
70
#tablerows("red" ["dadsdf","dsa"])
72
Variable reference: #set( $monkey = $bill )
73
String literal: #set( $monkey.Friend = 'monica' )
74
Property reference: #set( $monkey.Blame = $whitehouse.Leak )
75
Method reference: #set( $monkey.Plan = $spindoctor.weave($web) )
76
Number literal: #set( $monkey.Number = 123 )
77
Range operator: #set( $monkey.Numbers = [1..3] )
78
Object list: #set( $monkey.Say = ["Not", $my, "fault"] )
79
Object map: #set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"})
81
The RHS can also be a simple arithmetic expression, such as:
82
Addition: #set( $value = $foo + 1 )
83
Subtraction: #set( $value = $bar - 1 )
84
Multiplication: #set( $value = $foo * $bar )
85
Division: #set( $value = $foo / $bar )
86
Remainder: #set( $value = $foo % $bar )
90
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
100
<p><strong>MIME types defined:</strong> <code>text/velocity</code>.</p>