1
0

test.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "haml");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. // Requires at least one media query
  7. MT("elementName",
  8. "[tag %h1] Hey There");
  9. MT("oneElementPerLine",
  10. "[tag %h1] Hey There %h2");
  11. MT("idSelector",
  12. "[tag %h1][attribute #test] Hey There");
  13. MT("classSelector",
  14. "[tag %h1][attribute .hello] Hey There");
  15. MT("docType",
  16. "[tag !!! XML]");
  17. MT("comment",
  18. "[comment / Hello WORLD]");
  19. MT("notComment",
  20. "[tag %h1] This is not a / comment ");
  21. MT("attributes",
  22. "[tag %a]([variable title][operator =][string \"test\"]){[atom :title] [operator =>] [string \"test\"]}");
  23. MT("htmlCode",
  24. "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]");
  25. MT("rubyBlock",
  26. "[operator =][variable-2 @item]");
  27. MT("selectorRubyBlock",
  28. "[tag %a.selector=] [variable-2 @item]");
  29. MT("nestedRubyBlock",
  30. "[tag %a]",
  31. " [operator =][variable puts] [string \"test\"]");
  32. MT("multilinePlaintext",
  33. "[tag %p]",
  34. " Hello,",
  35. " World");
  36. MT("multilineRuby",
  37. "[tag %p]",
  38. " [comment -# this is a comment]",
  39. " [comment and this is a comment too]",
  40. " Date/Time",
  41. " [operator -] [variable now] [operator =] [tag DateTime][operator .][property now]",
  42. " [tag %strong=] [variable now]",
  43. " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])",
  44. " [operator =][string \"Happy\"]",
  45. " [operator =][string \"Belated\"]",
  46. " [operator =][string \"Birthday\"]");
  47. MT("multilineComment",
  48. "[comment /]",
  49. " [comment Multiline]",
  50. " [comment Comment]");
  51. MT("hamlComment",
  52. "[comment -# this is a comment]");
  53. MT("multilineHamlComment",
  54. "[comment -# this is a comment]",
  55. " [comment and this is a comment too]");
  56. MT("multilineHTMLComment",
  57. "[comment <!--]",
  58. " [comment what a comment]",
  59. " [comment -->]");
  60. MT("hamlAfterRubyTag",
  61. "[attribute .block]",
  62. " [tag %strong=] [variable now]",
  63. " [attribute .test]",
  64. " [operator =][variable now]",
  65. " [attribute .right]");
  66. MT("stretchedRuby",
  67. "[operator =] [variable puts] [string \"Hello\"],",
  68. " [string \"World\"]");
  69. MT("interpolationInHashAttribute",
  70. //"[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test");
  71. "[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test");
  72. MT("interpolationInHTMLAttribute",
  73. "[tag %div]([variable title][operator =][string \"#{][variable test][string }_#{][variable ting]()[string }\"]) Test");
  74. })();