~ubuntu-branches/ubuntu/utopic/codemirror-js/utopic

« back to all changes in this revision

Viewing changes to mode/velocity/index.html

  • Committer: Package Import Robot
  • Author(s): David Paleino
  • Date: 2012-04-12 12:25:28 UTC
  • Revision ID: package-import@ubuntu.com-20120412122528-8xp5a8frj4h1d3ee
Tags: upstream-2.23
ImportĀ upstreamĀ versionĀ 2.23

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html>
 
2
<html>
 
3
  <head>
 
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">
 
11
  </head>
 
12
  <body>
 
13
    <h1>CodeMirror: Velocity mode</h1>
 
14
    <form><textarea id="code" name="code">
 
15
## Velocity Code Demo
 
16
#*
 
17
   based on PL/SQL mode by Peter Raganitsch, adapted to Velocity by Steve O'Hara ( http://www.pivotal-solutions.co.uk )
 
18
   August 2011
 
19
*#
 
20
 
 
21
#*
 
22
   This is a multiline comment.
 
23
   This is the second line
 
24
*#
 
25
 
 
26
#[[ hello steve
 
27
   This has invalid syntax that would normally need "poor man's escaping" like:
 
28
 
 
29
   #define()
 
30
 
 
31
   ${blah
 
32
]]#
 
33
 
 
34
#include( "disclaimer.txt" "opinion.txt" )
 
35
#include( $foo $bar )
 
36
 
 
37
#parse( "lecorbusier.vm" )
 
38
#parse( $foo )
 
39
 
 
40
#evaluate( 'string with VTL #if(true)will be displayed#end' )
 
41
 
 
42
#define( $hello ) Hello $who #end #set( $who = "World!") $hello ## displays Hello World!
 
43
 
 
44
#foreach( $customer in $customerList )
 
45
 
 
46
    $foreach.count $customer.Name
 
47
 
 
48
    #if( $foo == ${bar})
 
49
        it's true!
 
50
        #break
 
51
    #{else}
 
52
        it's not!
 
53
        #stop
 
54
    #end
 
55
 
 
56
    #if ($foreach.parent.hasNext)
 
57
        $velocityCount
 
58
    #end
 
59
#end
 
60
 
 
61
$someObject.getValues("this is a string split
 
62
        across lines")
 
63
 
 
64
#macro( tablerows $color $somelist )
 
65
    #foreach( $something in $somelist )
 
66
        <tr><td bgcolor=$color>$something</td></tr>
 
67
    #end
 
68
#end
 
69
 
 
70
#tablerows("red" ["dadsdf","dsa"])
 
71
 
 
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"})
 
80
 
 
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 )
 
87
 
 
88
</textarea></form>
 
89
    <script>
 
90
      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
 
91
        tabMode: "indent",
 
92
        matchBrackets: true,
 
93
        theme: "night",
 
94
        lineNumbers: true,
 
95
        indentUnit: 4,
 
96
        mode: "text/velocity"
 
97
      });
 
98
    </script>
 
99
 
 
100
    <p><strong>MIME types defined:</strong> <code>text/velocity</code>.</p>
 
101
 
 
102
  </body>
 
103
</html>