htmlbars.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. module.exports = function(hljs) {
  2. var BUILT_INS = 'action collection component concat debugger each each-in else get hash if input link-to loc log mut outlet partial query-params render textarea unbound unless with yield view';
  3. var ATTR_ASSIGNMENT = {
  4. illegal: /\}\}/,
  5. begin: /[a-zA-Z0-9_]+=/,
  6. returnBegin: true,
  7. relevance: 0,
  8. contains: [
  9. {
  10. className: 'attr', begin: /[a-zA-Z0-9_]+/
  11. }
  12. ]
  13. };
  14. var SUB_EXPR = {
  15. illegal: /\}\}/,
  16. begin: /\)/, end: /\)/,
  17. contains: [
  18. {
  19. begin: /[a-zA-Z\.\-]+/,
  20. keywords: {built_in: BUILT_INS},
  21. starts: {
  22. endsWithParent: true, relevance: 0,
  23. contains: [
  24. hljs.QUOTE_STRING_MODE,
  25. ]
  26. }
  27. }
  28. ]
  29. };
  30. var TAG_INNARDS = {
  31. endsWithParent: true, relevance: 0,
  32. keywords: {keyword: 'as', built_in: BUILT_INS},
  33. contains: [
  34. hljs.QUOTE_STRING_MODE,
  35. ATTR_ASSIGNMENT,
  36. hljs.NUMBER_MODE
  37. ]
  38. };
  39. return {
  40. case_insensitive: true,
  41. subLanguage: 'xml',
  42. contains: [
  43. hljs.COMMENT('{{!(--)?', '(--)?}}'),
  44. {
  45. className: 'template-tag',
  46. begin: /\{\{[#\/]/, end: /\}\}/,
  47. contains: [
  48. {
  49. className: 'name',
  50. begin: /[a-zA-Z\.\-]+/,
  51. keywords: {'builtin-name': BUILT_INS},
  52. starts: TAG_INNARDS
  53. }
  54. ]
  55. },
  56. {
  57. className: 'template-variable',
  58. begin: /\{\{[a-zA-Z][a-zA-Z\-]+/, end: /\}\}/,
  59. keywords: {keyword: 'as', built_in: BUILT_INS},
  60. contains: [
  61. hljs.QUOTE_STRING_MODE
  62. ]
  63. }
  64. ]
  65. };
  66. };