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.

474 lines
15KB

  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: Handlebars
  5. file_extensions:
  6. - handlebars
  7. - handlebars.html
  8. - hbr
  9. - hbrs
  10. - hbs
  11. - hdbs
  12. - hjs
  13. - mu
  14. - mustache
  15. - rac
  16. - stache
  17. - template
  18. - tmpl
  19. scope: text.html.handlebars
  20. contexts:
  21. main:
  22. - include: yfm
  23. - include: extends
  24. - include: block_comments
  25. - include: comments
  26. - include: block_helper
  27. - include: end_block
  28. - include: else_token
  29. - include: partial_and_var
  30. - include: inline_script
  31. - include: html_tags
  32. - include: scope:text.html.basic
  33. block_comments:
  34. - match: '\{\{!--'
  35. push:
  36. - meta_scope: comment.block.handlebars
  37. - match: '--\}\}'
  38. pop: true
  39. - match: '@\w*'
  40. scope: keyword.annotation.handlebars
  41. - include: comments
  42. - match: <!--
  43. captures:
  44. 0: punctuation.definition.comment.html
  45. push:
  46. - meta_scope: comment.block.html
  47. - match: '-{2,3}\s*>'
  48. captures:
  49. 0: punctuation.definition.comment.html
  50. pop: true
  51. - match: "--"
  52. scope: invalid.illegal.bad-comments-or-CDATA.html
  53. block_helper:
  54. - match: '(\{\{~?\#)([-a-zA-Z0-9_\./>]+)\s?(@?[-a-zA-Z0-9_\./]+)*\s?(@?[-a-zA-Z0-9_\./]+)*\s?(@?[-a-zA-Z0-9_\./]+)*'
  55. captures:
  56. 1: support.constant.handlebars
  57. 2: support.constant.handlebars
  58. 3: variable.parameter.handlebars
  59. 4: support.constant.handlebars
  60. 5: variable.parameter.handlebars
  61. 6: support.constant.handlebars
  62. push:
  63. - meta_scope: meta.function.block.start.handlebars
  64. - match: '(~?\}\})'
  65. captures:
  66. 1: support.constant.handlebars
  67. pop: true
  68. - include: string
  69. - include: handlebars_attribute
  70. comments:
  71. - match: '\{\{!'
  72. push:
  73. - meta_scope: comment.block.handlebars
  74. - match: '\}\}'
  75. pop: true
  76. - match: '@\w*'
  77. scope: keyword.annotation.handlebars
  78. - include: comments
  79. - match: <!--
  80. captures:
  81. 0: punctuation.definition.comment.html
  82. push:
  83. - meta_scope: comment.block.html
  84. - match: '-{2,3}\s*>'
  85. captures:
  86. 0: punctuation.definition.comment.html
  87. pop: true
  88. - match: "--"
  89. scope: invalid.illegal.bad-comments-or-CDATA.html
  90. else_token:
  91. - match: '(\{\{~?else)(@?\s(if)\s([-a-zA-Z0-9_\./]+))?'
  92. captures:
  93. 1: support.constant.handlebars
  94. 3: support.constant.handlebars
  95. 4: variable.parameter.handlebars
  96. push:
  97. - meta_scope: meta.function.inline.else.handlebars
  98. - match: '(~?\}\}\}*)'
  99. captures:
  100. 1: support.constant.handlebars
  101. pop: true
  102. end_block:
  103. - match: '(\{\{~?/)([a-zA-Z0-9/_\.-]+)\s*'
  104. captures:
  105. 1: support.constant.handlebars
  106. 2: support.constant.handlebars
  107. push:
  108. - meta_scope: meta.function.block.end.handlebars
  109. - match: '(~?\}\})'
  110. captures:
  111. 1: support.constant.handlebars
  112. pop: true
  113. entities:
  114. - match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)"
  115. scope: constant.character.entity.html
  116. captures:
  117. 1: punctuation.definition.entity.html
  118. 3: punctuation.definition.entity.html
  119. - match: "&"
  120. scope: invalid.illegal.bad-ampersand.html
  121. escaped-double-quote:
  122. - match: \\"
  123. scope: constant.character.escape.js
  124. escaped-single-quote:
  125. - match: \\'
  126. scope: constant.character.escape.js
  127. extends:
  128. - match: '(\{\{!<)\s([-a-zA-Z0-9_\./]+)'
  129. captures:
  130. 1: support.function.handlebars
  131. 2: support.class.handlebars
  132. push:
  133. - meta_scope: meta.preprocessor.handlebars
  134. - match: '(\}\})'
  135. captures:
  136. 1: support.function.handlebars
  137. pop: true
  138. handlebars_attribute:
  139. - include: handlebars_attribute_name
  140. - include: handlebars_attribute_value
  141. handlebars_attribute_name:
  142. - match: '\b([-a-zA-Z0-9_\.]+)\b='
  143. captures:
  144. 1: variable.parameter.handlebars
  145. push:
  146. - meta_scope: entity.other.attribute-name.handlebars
  147. - match: (?='|"|)
  148. captures:
  149. 1: variable.parameter.handlebars
  150. pop: true
  151. handlebars_attribute_value:
  152. - match: '([-a-zA-Z0-9_\./]+)\b'
  153. captures:
  154. 1: variable.parameter.handlebars
  155. push:
  156. - meta_scope: entity.other.attribute-value.handlebars
  157. - match: ('|"|)
  158. captures:
  159. 1: variable.parameter.handlebars
  160. pop: true
  161. - include: string
  162. html_tags:
  163. - match: '(<)([a-zA-Z0-9:-]+)(?=[^>]*></\2>)'
  164. captures:
  165. 1: punctuation.definition.tag.html
  166. 2: entity.name.tag.html
  167. push:
  168. - meta_scope: meta.tag.any.html
  169. - match: (>(<)/)(\2)(>)
  170. captures:
  171. 1: punctuation.definition.tag.html
  172. 2: meta.scope.between-tag-pair.html
  173. 3: entity.name.tag.html
  174. 4: punctuation.definition.tag.html
  175. pop: true
  176. - include: tag-stuff
  177. - match: (<\?)(xml)
  178. captures:
  179. 1: punctuation.definition.tag.html
  180. 2: entity.name.tag.xml.html
  181. push:
  182. - meta_scope: meta.tag.preprocessor.xml.html
  183. - match: (\?>)
  184. captures:
  185. 1: punctuation.definition.tag.html
  186. 2: entity.name.tag.xml.html
  187. pop: true
  188. - include: tag_generic_attribute
  189. - include: string
  190. - match: <!--
  191. captures:
  192. 0: punctuation.definition.comment.html
  193. push:
  194. - meta_scope: comment.block.html
  195. - match: '--\s*>'
  196. captures:
  197. 0: punctuation.definition.comment.html
  198. pop: true
  199. - match: "--"
  200. scope: invalid.illegal.bad-comments-or-CDATA.html
  201. - match: <!
  202. captures:
  203. 0: punctuation.definition.tag.html
  204. push:
  205. - meta_scope: meta.tag.sgml.html
  206. - match: ">"
  207. captures:
  208. 0: punctuation.definition.tag.html
  209. pop: true
  210. - match: (DOCTYPE|doctype)
  211. captures:
  212. 1: entity.name.tag.doctype.html
  213. push:
  214. - meta_scope: meta.tag.sgml.doctype.html
  215. - match: (?=>)
  216. captures:
  217. 1: entity.name.tag.doctype.html
  218. pop: true
  219. - match: '"[^">]*"'
  220. scope: string.quoted.double.doctype.identifiers-and-DTDs.html
  221. - match: '\[CDATA\['
  222. push:
  223. - meta_scope: constant.other.inline-data.html
  224. - match: "]](?=>)"
  225. pop: true
  226. - match: (\s*)(?!--|>)\S(\s*)
  227. scope: invalid.illegal.bad-comments-or-CDATA.html
  228. - match: '(?:^\s+)?(<)((?i:style))\b(?![^>]*/>)'
  229. captures:
  230. 1: punctuation.definition.tag.html
  231. 2: entity.name.tag.style.html
  232. 3: punctuation.definition.tag.html
  233. push:
  234. - meta_scope: source.css.embedded.html
  235. - match: (</)((?i:style))(>)(?:\s*\n)?
  236. captures:
  237. 1: punctuation.definition.tag.html
  238. 2: entity.name.tag.style.html
  239. 3: punctuation.definition.tag.html
  240. pop: true
  241. - include: tag-stuff
  242. - match: (>)
  243. captures:
  244. 1: punctuation.definition.tag.html
  245. push:
  246. - match: (?=</(?i:style))
  247. pop: true
  248. - include: scope:source.css
  249. - match: '(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)'
  250. captures:
  251. 1: punctuation.definition.tag.html
  252. 2: entity.name.tag.script.html
  253. push:
  254. - meta_scope: source.js.embedded.html
  255. - match: (?<=</(script|SCRIPT))(>)(?:\s*\n)?
  256. captures:
  257. 2: punctuation.definition.tag.html
  258. pop: true
  259. - include: tag-stuff
  260. - match: (?<!</(?:script|SCRIPT))(>)
  261. captures:
  262. 1: punctuation.definition.tag.html
  263. 2: entity.name.tag.script.html
  264. push:
  265. - match: (</)((?i:script))
  266. captures:
  267. 1: punctuation.definition.tag.html
  268. 2: entity.name.tag.script.html
  269. pop: true
  270. - match: (//).*?((?=</script)|$\n?)
  271. scope: comment.line.double-slash.js
  272. captures:
  273. 1: punctuation.definition.comment.js
  274. - match: /\*
  275. captures:
  276. 0: punctuation.definition.comment.js
  277. push:
  278. - meta_scope: comment.block.js
  279. - match: \*/|(?=</script)
  280. captures:
  281. 0: punctuation.definition.comment.js
  282. pop: true
  283. - include: scope:source.js
  284. - match: (</?)((?i:body|head|html)\b)
  285. captures:
  286. 1: punctuation.definition.tag.html
  287. 2: entity.name.tag.structure.any.html
  288. push:
  289. - meta_scope: meta.tag.structure.any.html
  290. - match: (>)
  291. captures:
  292. 1: punctuation.definition.tag.html
  293. 2: entity.name.tag.structure.any.html
  294. pop: true
  295. - include: tag-stuff
  296. - match: (</?)((?i:address|blockquote|dd|div|header|section|footer|aside|nav|dl|dt|fieldset|form|frame|frameset|h1|h2|h3|h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|menu|pre)\b)
  297. captures:
  298. 1: punctuation.definition.tag.html
  299. 2: entity.name.tag.block.any.html
  300. push:
  301. - meta_scope: meta.tag.block.any.html
  302. - match: (>)
  303. captures:
  304. 1: punctuation.definition.tag.html
  305. 2: entity.name.tag.block.any.html
  306. pop: true
  307. - include: tag-stuff
  308. - match: (</?)((?i:a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var)\b)
  309. captures:
  310. 1: punctuation.definition.tag.html
  311. 2: entity.name.tag.inline.any.html
  312. push:
  313. - meta_scope: meta.tag.inline.any.html
  314. - match: "((?: ?/)?>)"
  315. captures:
  316. 1: punctuation.definition.tag.html
  317. 2: entity.name.tag.inline.any.html
  318. pop: true
  319. - include: tag-stuff
  320. - match: "(</?)([a-zA-Z0-9:-]+)"
  321. captures:
  322. 1: punctuation.definition.tag.html
  323. 2: entity.name.tag.other.html
  324. push:
  325. - meta_scope: meta.tag.other.html
  326. - match: (>)
  327. captures:
  328. 1: punctuation.definition.tag.html
  329. 2: entity.name.tag.other.html
  330. pop: true
  331. - include: tag-stuff
  332. - match: "(</?)([a-zA-Z0-9{}:-]+)"
  333. captures:
  334. 1: punctuation.definition.tag.html
  335. 2: entity.name.tag.tokenised.html
  336. push:
  337. - meta_scope: meta.tag.tokenised.html
  338. - match: (>)
  339. captures:
  340. 1: punctuation.definition.tag.html
  341. 2: entity.name.tag.tokenised.html
  342. pop: true
  343. - include: tag-stuff
  344. - include: entities
  345. - match: <>
  346. scope: invalid.illegal.incomplete.html
  347. - match: <
  348. scope: invalid.illegal.bad-angle-bracket.html
  349. inline_script:
  350. - match: '(?:^\s+)?(<)((?i:script))\b(?:.*(type)=(["''](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)["'']))(?![^>]*/>)'
  351. captures:
  352. 1: punctuation.definition.tag.html
  353. 2: entity.name.tag.script.html
  354. 3: entity.other.attribute-name.html
  355. 4: string.quoted.double.html
  356. push:
  357. - meta_scope: source.handlebars.embedded.html
  358. - match: (?<=</(script|SCRIPT))(>)(?:\s*\n)?
  359. captures:
  360. 2: punctuation.definition.tag.html
  361. pop: true
  362. - include: tag-stuff
  363. - match: (?<!</(?:script|SCRIPT))(>)
  364. captures:
  365. 1: punctuation.definition.tag.html
  366. 2: entity.name.tag.script.html
  367. push:
  368. - match: (</)((?i:script))
  369. captures:
  370. 1: punctuation.definition.tag.html
  371. 2: entity.name.tag.script.html
  372. pop: true
  373. - include: block_comments
  374. - include: comments
  375. - include: block_helper
  376. - include: end_block
  377. - include: else_token
  378. - include: partial_and_var
  379. - include: html_tags
  380. - include: scope:text.html.basic
  381. partial_and_var:
  382. - match: '(\{\{~?\{*(>|!<)*)\s*(@?[-a-zA-Z0-9$_\./]+)*'
  383. captures:
  384. 1: support.constant.handlebars
  385. 3: variable.parameter.handlebars
  386. push:
  387. - meta_scope: meta.function.inline.other.handlebars
  388. - match: '(~?\}\}\}*)'
  389. captures:
  390. 1: support.constant.handlebars
  391. pop: true
  392. - include: string
  393. - include: handlebars_attribute
  394. string:
  395. - include: string-single-quoted
  396. - include: string-double-quoted
  397. string-double-quoted:
  398. - match: '"'
  399. captures:
  400. 0: punctuation.definition.string.begin.html
  401. push:
  402. - meta_scope: string.quoted.double.handlebars
  403. - match: '"'
  404. captures:
  405. 0: punctuation.definition.string.end.html
  406. pop: true
  407. - include: escaped-double-quote
  408. - include: block_comments
  409. - include: comments
  410. - include: block_helper
  411. - include: else_token
  412. - include: end_block
  413. - include: partial_and_var
  414. string-single-quoted:
  415. - match: "'"
  416. captures:
  417. 0: punctuation.definition.string.begin.html
  418. push:
  419. - meta_scope: string.quoted.single.handlebars
  420. - match: "'"
  421. captures:
  422. 0: punctuation.definition.string.end.html
  423. pop: true
  424. - include: escaped-single-quote
  425. - include: block_comments
  426. - include: comments
  427. - include: block_helper
  428. - include: else_token
  429. - include: end_block
  430. - include: partial_and_var
  431. tag-stuff:
  432. - include: tag_id_attribute
  433. - include: tag_generic_attribute
  434. - include: string
  435. - include: block_comments
  436. - include: comments
  437. - include: block_helper
  438. - include: end_block
  439. - include: else_token
  440. - include: partial_and_var
  441. tag_generic_attribute:
  442. - match: '\b([a-zA-Z0-9_-]+)\b\s*(=)'
  443. captures:
  444. 1: entity.other.attribute-name.generic.html
  445. 2: punctuation.separator.key-value.html
  446. push:
  447. - meta_scope: entity.other.attribute-name.html
  448. - match: (?<='|"|)
  449. captures:
  450. 1: entity.other.attribute-name.generic.html
  451. 2: punctuation.separator.key-value.html
  452. pop: true
  453. - include: string
  454. tag_id_attribute:
  455. - match: \b(id)\b\s*(=)
  456. captures:
  457. 1: entity.other.attribute-name.id.html
  458. 2: punctuation.separator.key-value.html
  459. push:
  460. - meta_scope: meta.attribute-with-value.id.html
  461. - match: (?<='|"|)
  462. captures:
  463. 1: entity.other.attribute-name.id.html
  464. 2: punctuation.separator.key-value.html
  465. pop: true
  466. - include: string
  467. yfm:
  468. - match: (?<!\s)---\n$
  469. push:
  470. - meta_scope: markup.raw.yaml.front-matter
  471. - match: ^---\s
  472. pop: true
  473. - include: scope:source.yaml