source: node_modules/refractor/lang/handlebars.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1'use strict'
2var refractorMarkupTemplating = require('./markup-templating.js')
3module.exports = handlebars
4handlebars.displayName = 'handlebars'
5handlebars.aliases = ['hbs']
6function handlebars(Prism) {
7 Prism.register(refractorMarkupTemplating)
8 ;(function (Prism) {
9 Prism.languages.handlebars = {
10 comment: /\{\{![\s\S]*?\}\}/,
11 delimiter: {
12 pattern: /^\{\{\{?|\}\}\}?$/,
13 alias: 'punctuation'
14 },
15 string: /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
16 number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][+-]?\d+)?/,
17 boolean: /\b(?:false|true)\b/,
18 block: {
19 pattern: /^(\s*(?:~\s*)?)[#\/]\S+?(?=\s*(?:~\s*)?$|\s)/,
20 lookbehind: true,
21 alias: 'keyword'
22 },
23 brackets: {
24 pattern: /\[[^\]]+\]/,
25 inside: {
26 punctuation: /\[|\]/,
27 variable: /[\s\S]+/
28 }
29 },
30 punctuation: /[!"#%&':()*+,.\/;<=>@\[\\\]^`{|}~]/,
31 variable: /[^!"#%&'()*+,\/;<=>@\[\\\]^`{|}~\s]+/
32 }
33 Prism.hooks.add('before-tokenize', function (env) {
34 var handlebarsPattern = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g
35 Prism.languages['markup-templating'].buildPlaceholders(
36 env,
37 'handlebars',
38 handlebarsPattern
39 )
40 })
41 Prism.hooks.add('after-tokenize', function (env) {
42 Prism.languages['markup-templating'].tokenizePlaceholders(
43 env,
44 'handlebars'
45 )
46 })
47 Prism.languages.hbs = Prism.languages.handlebars
48 })(Prism)
49}
Note: See TracBrowser for help on using the repository browser.