Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #macro( tablerows $color $somelist )
  62. #foreach( $something in $somelist )
  63. <tr><td bgcolor=$color>$something</td></tr>
  64. <tr><td bgcolor=$color>$bodyContent</td></tr>
  65. #end
  66. #end
  67. #tablerows("red" ["dadsdf","dsa"])
  68. #@tablerows("red" ["dadsdf","dsa"]) some body content #end
  69. Variable reference: #set( $monkey = $bill )
  70. String literal: #set( $monkey.Friend = 'monica' )
  71. Property reference: #set( $monkey.Blame = $whitehouse.Leak )
  72. Method reference: #set( $monkey.Plan = $spindoctor.weave($web) )
  73. Number literal: #set( $monkey.Number = 123 )
  74. Range operator: #set( $monkey.Numbers = [1..3] )
  75. Object list: #set( $monkey.Say = ["Not", $my, "fault"] )
  76. Object map: #set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"})
  77. The RHS can also be a simple arithmetic expression, such as:
  78. Addition: #set( $value = $foo + 1 )
  79. Subtraction: #set( $value = $bar - 1 )
  80. Multiplication: #set( $value = $foo * $bar )
  81. Division: #set( $value = $foo / $bar )
  82. Remainder: #set( $value = $foo % $bar )
  83. </textarea></form>
  84. <script>
  85. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  86. theme: "night",
  87. lineNumbers: true,
  88. indentUnit: 4,
  89. mode: "text/velocity"
  90. });
  91. </script>
  92. <p><strong>MIME types defined:</strong> <code>text/velocity</code>.</p>
  93. </article>