1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/twig.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Twig
Requires: xml.js
Author: Luke Holder <lukemh@gmail.com>
Description: Twig is a templating language for PHP
Website: https://twig.symfony.com
Category: template
*/
function twig(hljs) {
2023-12-18 13:12:25 +08:00
var PARAMS = {
className: 'params',
begin: '\\(', end: '\\)'
};
var FUNCTION_NAMES = 'attribute block constant cycle date dump include ' +
'max min parent random range source template_from_string';
var FUNCTIONS = {
beginKeywords: FUNCTION_NAMES,
keywords: {name: FUNCTION_NAMES},
relevance: 0,
contains: [
PARAMS
]
};
var FILTER = {
begin: /\|[A-Za-z_]+:?/,
keywords:
2024-01-16 21:26:16 +08:00
'abs batch capitalize column convert_encoding date date_modify default ' +
'escape filter first format inky_to_html inline_css join json_encode keys last ' +
'length lower map markdown merge nl2br number_format raw reduce replace ' +
'reverse round slice sort spaceless split striptags title trim upper url_encode',
2023-12-18 13:12:25 +08:00
contains: [
FUNCTIONS
]
};
2024-01-16 21:26:16 +08:00
var TAGS = 'apply autoescape block deprecated do embed extends filter flush for from ' +
'if import include macro sandbox set use verbatim with';
2023-12-18 13:12:25 +08:00
TAGS = TAGS + ' ' + TAGS.split(' ').map(function(t){return 'end' + t}).join(' ');
return {
2024-01-16 21:26:16 +08:00
name: 'Twig',
2023-12-18 13:12:25 +08:00
aliases: ['craftcms'],
case_insensitive: true,
subLanguage: 'xml',
contains: [
2024-01-16 21:26:16 +08:00
hljs.COMMENT(/\{#/, /#\}/),
2023-12-18 13:12:25 +08:00
{
className: 'template-tag',
2024-01-16 21:26:16 +08:00
begin: /\{%/, end: /%\}/,
2023-12-18 13:12:25 +08:00
contains: [
{
className: 'name',
begin: /\w+/,
keywords: TAGS,
starts: {
endsWithParent: true,
contains: [FILTER, FUNCTIONS],
relevance: 0
}
}
]
},
{
className: 'template-variable',
2024-01-16 21:26:16 +08:00
begin: /\{\{/, end: /\}\}/,
2023-12-18 13:12:25 +08:00
contains: ['self', FILTER, FUNCTIONS]
}
]
};
2024-01-16 21:26:16 +08:00
}
module.exports = twig;