| 5 |
lars |
1 |
<!doctype html>
|
|
|
2 |
<title>CodeMirror: Velocity mode</title>
|
|
|
3 |
<meta charset="utf-8" />
|
|
|
4 |
<link rel=stylesheet href="../../doc/docs.css">
|
|
|
5 |
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
|
6 |
<link rel="stylesheet" href="../../theme/night.css">
|
|
|
7 |
<script src="../../lib/codemirror.js"></script>
|
|
|
8 |
<script src="velocity.js"></script>
|
|
|
9 |
<style>
|
|
|
10 |
.CodeMirror {
|
|
|
11 |
border: 1px solid black;
|
|
|
12 |
}
|
|
|
13 |
</style>
|
|
|
14 |
<div id=nav>
|
|
|
15 |
<a href="http://codemirror.net">
|
|
|
16 |
<h1>CodeMirror</h1>
|
|
|
17 |
<img id=logo src="../../doc/logo.png">
|
|
|
18 |
</a>
|
|
|
19 |
<ul>
|
|
|
20 |
<li>
|
|
|
21 |
<a href="../../index.html">Home</a>
|
|
|
22 |
<li>
|
|
|
23 |
<a href="../../doc/manual.html">Manual</a>
|
|
|
24 |
<li>
|
|
|
25 |
<a href="https://github.com/codemirror/codemirror">Code</a>
|
|
|
26 |
</ul>
|
|
|
27 |
<ul>
|
|
|
28 |
<li>
|
|
|
29 |
<a href="../index.html">Language modes</a>
|
|
|
30 |
<li>
|
|
|
31 |
<a class=active href="#">Velocity</a>
|
|
|
32 |
</ul>
|
|
|
33 |
</div>
|
|
|
34 |
<article>
|
|
|
35 |
<h2>Velocity mode</h2>
|
|
|
36 |
<form>
|
|
|
37 |
<textarea id="code" name="code"> ## Velocity Code Demo #* based on PL/SQL mode by Peter Raganitsch, adapted to Velocity by Steve O'Hara ( http://www.pivotal-solutions.co.uk ) August 2011 *# #* This is a multiline comment. This is the second line *# #[[ hello steve This has invalid
|
|
|
38 |
syntax that would normally need "poor man's escaping" like: #define() ${blah ]]# #include( "disclaimer.txt" "opinion.txt" ) #include( $foo $bar ) #parse( "lecorbusier.vm" ) #parse( $foo ) #evaluate( 'string with VTL #if(true)will be displayed#end'
|
|
|
39 |
) #define( $hello ) Hello $who #end #set( $who = "World!") $hello ## displays Hello World! #foreach( $customer in $customerList ) $foreach.count $customer.Name #if( $foo == ${bar}) it's true! #break #{else} it's not! #stop #end #if ($foreach.parent.hasNext)
|
|
|
40 |
$velocityCount #end #end $someObject.getValues("this is a string split across lines") $someObject("This plus $something in the middle").method(7567).property #macro( tablerows $color $somelist ) #foreach( $something in $somelist )
|
|
|
41 |
<tr>
|
|
|
42 |
<td bgcolor=$color>$something</td>
|
|
|
43 |
</tr>
|
|
|
44 |
<tr>
|
|
|
45 |
<td bgcolor=$color>$bodyContent</td>
|
|
|
46 |
</tr> #end #end #tablerows("red" ["dadsdf","dsa"]) #@tablerows("red" ["dadsdf","dsa"]) some body content #end Variable reference: #set( $monkey = $bill ) String literal: #set( $monkey.Friend = 'monica' ) Property reference: #set( $monkey.Blame =
|
|
|
47 |
$whitehouse.Leak ) Method reference: #set( $monkey.Plan = $spindoctor.weave($web) ) Number literal: #set( $monkey.Number = 123 ) Range operator: #set( $monkey.Numbers = [1..3] ) Object list: #set( $monkey.Say = ["Not", $my, "fault"] ) Object
|
|
|
48 |
map: #set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"}) The RHS can also be a simple arithmetic expression, such as: Addition: #set( $value = $foo + 1 ) Subtraction: #set( $value = $bar - 1 ) Multiplication: #set( $value = $foo
|
|
|
49 |
* $bar ) Division: #set( $value = $foo / $bar ) Remainder: #set( $value = $foo % $bar ) </textarea>
|
|
|
50 |
</form>
|
|
|
51 |
<script>
|
|
|
52 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"),
|
|
|
53 |
{
|
|
|
54 |
theme: "night",
|
|
|
55 |
lineNumbers: true,
|
|
|
56 |
indentUnit: 4,
|
|
|
57 |
mode: "text/velocity"
|
|
|
58 |
});
|
|
|
59 |
</script>
|
|
|
60 |
<p>
|
|
|
61 |
<strong>MIME types defined:</strong> <code>text/velocity</code>.</p>
|
|
|
62 |
</article>
|