text/js/handlebars-Cym-9yHt.chunk.m...

1 строка
9.5 KiB
Plaintext
Исходник Постоянная ссылка Обычный вид История

{"version":3,"file":"handlebars-Cym-9yHt.chunk.mjs","sources":["../node_modules/highlight.js/lib/languages/handlebars.js"],"sourcesContent":["/*\nLanguage: Handlebars\nRequires: xml.js\nAuthor: Robin Ward <robin.ward@gmail.com>\nDescription: Matcher for Handlebars as well as EmberJS additions.\nWebsite: https://handlebarsjs.com\nCategory: template\n*/\n\nfunction handlebars(hljs) {\n const regex = hljs.regex;\n const BUILT_INS = {\n $pattern: /[\\w.\\/]+/,\n built_in: [\n 'action',\n 'bindattr',\n 'collection',\n 'component',\n 'concat',\n 'debugger',\n 'each',\n 'each-in',\n 'get',\n 'hash',\n 'if',\n 'in',\n 'input',\n 'link-to',\n 'loc',\n 'log',\n 'lookup',\n 'mut',\n 'outlet',\n 'partial',\n 'query-params',\n 'render',\n 'template',\n 'textarea',\n 'unbound',\n 'unless',\n 'view',\n 'with',\n 'yield'\n ]\n };\n\n const LITERALS = {\n $pattern: /[\\w.\\/]+/,\n literal: [\n 'true',\n 'false',\n 'undefined',\n 'null'\n ]\n };\n\n // as defined in https://handlebarsjs.com/guide/expressions.html#literal-segments\n // this regex matches literal segments like ' abc ' or [ abc ] as well as helpers and paths\n // like a/b, ./abc/cde, and abc.bcd\n\n const DOUBLE_QUOTED_ID_REGEX = /\"\"|\"[^\"]+\"/;\n const SINGLE_QUOTED_ID_REGEX = /''|'[^']+'/;\n const BRACKET_QUOTED_ID_REGEX = /\\[\\]|\\[[^\\]]+\\]/;\n const PLAIN_ID_REGEX = /[^\\s!\"#%&'()*+,.\\/;<=>@\\[\\\\\\]^`{|}~]+/;\n const PATH_DELIMITER_REGEX = /(\\.|\\/)/;\n const ANY_ID = regex.either(\n DOUBLE_QUOTED_ID_REGEX,\n SINGLE_QUOTED_ID_REGEX,\n BRACKET_QUOTED_ID_REGEX,\n PLAIN_ID_REGEX\n );\n\n const IDENTIFIER_REGEX = regex.concat(\n regex.optional(/\\.|\\.\\/|\\//), // relative or absolute path\n ANY_ID,\n regex.anyNumberOfTimes(regex.concat(\n PATH_DELIMITER_REGEX,\n ANY_ID\n ))\n );\n\n // identifier followed by a equal-sign (without the equal sign)\n const HASH_PARAM_REGEX = regex.concat(\n '(',\n BRACKET_QUOTED_ID_REGEX, '|',\n PLAIN_ID_REGEX,\n ')(?==)'\n );\n\n const HELPER_NAME_OR_PATH_EXPRESSION = { begin: IDENTIFIER_REGEX };\n\n const HELPER_PARAMETER = hljs.inherit(HELPER_NAME_OR_PATH_EXPRESSION, { keywords: LITERALS });\n\n const SUB_EXPRESSION = {\n begin: /\\(/,\n end: /\\)/\n // the \"contains\" is added below when all necessary sub-modes are defined\n };\n\n const HASH = {\n // fka \"attribute-assignment\", parameters of the form 'key=value'\n className: 'attr',\n begin: HASH_PARAM_REGEX,\n relevance: 0,\n starts: {\n begin: /=/,\n end: /=/,\n starts: { contains: [\n hljs.NUMBER_MODE,\n hljs.QUOTE_STRING_MODE,\n hljs.APOS_STRING_MODE,\n HELPER_PARAMETER,\n SUB_EXPRESSION\n ] }\n }\n };\n\n const BLOCK_PARAMS = {\n // parameters of the form '{{#with x as | y |}}...{{/with}}'\n begin: /as\\s+\\|/,\n keywords: { keyword: 'as' },\n end: /\\|/,\n contains: [\n {\n // define sub-mode in order to prevent highlighting of block-parameter named \"as\"\n begin: /\\w+/ }\n ]\n };\n\n const HELPER_PARAMETERS = {\n contains: [\n hljs.NUMBER_MODE,\n hljs.QUOTE_STRING_MODE,\n hljs.APOS_STRING_MODE,\n BLOCK_PARAMS,\n HASH,\n HELPER_PARAMETER,\n SUB_EXPRESSION\n ],\n returnEnd: true\n // the property \"end\" is defined through inheritance when the mode is used. If depends\n // on the surrounding mode, but \"endsWithParent\" does not work here (i.e. it includes the\n // end-token of the surrounding mode)\n };\n\n const SUB_EXPRESSION_CONTENTS = hljs.inherit(HELPER_NAME_OR_PATH_EXPRESSION, {\n className: 'name',\n keywords: BUILT_INS,\n starts: hljs.inherit(HELPER_PARAMETERS, { end: /\\)/ })\n });\n\n SUB_EXPRESSION.contains = [ SUB_EXPRESSION_CONTENTS ];\n\n const OPENING_BLOCK_MUSTACHE_CONTENTS = hljs.inherit(HELPER_NAME_OR_PATH_EXPRE