index.html 3.2 KB

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