test.js 2.9 KB

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