Add support for Velocity. Fix #1372 (#1378)

This commit is contained in:
Golmote 2018-04-11 08:44:44 +02:00 committed by GitHub
parent 1bfc084836
commit 5a524f7e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 739 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -658,6 +658,11 @@
"require": "basic",
"owner": "Bigsby"
},
"velocity": {
"title": "Velocity",
"require": "markup",
"owner": "Golmote"
},
"verilog": {
"title": "Verilog",
"owner": "a-rey"

View File

@ -0,0 +1,72 @@
(function (Prism) {
Prism.languages.velocity = Prism.languages.extend('markup', {});
var velocity = {
'variable': {
pattern: /(^|[^\\](?:\\\\)*)\$!?(?:[a-z][\w-]*(?:\([^)]*\))?(?:\.[a-z][\w-]*(?:\([^)]*\))?|\[[^\]]+])*|{[^}]+})/i,
lookbehind: true,
inside: {} // See below
},
'string': {
pattern: /"[^"]*"|'[^']*'/,
greedy: true
},
'number': /\b\d+\b/,
'boolean': /\b(?:true|false)\b/,
'operator': /[=!<>]=?|[+*/%-]|&&|\|\||\.\.|\b(?:eq|g[et]|l[et]|n(?:e|ot))\b/,
'punctuation': /[(){}[\]:,.]/
};
velocity.variable.inside = {
'string': velocity['string'],
'function': {
pattern: /([^\w-])[a-z][\w-]*(?=\()/,
lookbehind: true
},
'number': velocity['number'],
'boolean': velocity['boolean'],
'punctuation': velocity['punctuation']
};
Prism.languages.insertBefore('velocity', 'comment', {
'unparsed': {
pattern: /(^|[^\\])#\[\[[\s\S]*?]]#/,
lookbehind: true,
greedy: true,
inside: {
'punctuation': /^#\[\[|]]#$/
}
},
'velocity-comment': [
{
pattern: /(^|[^\\])#\*[\s\S]*?\*#/,
lookbehind: true,
greedy: true,
alias: 'comment'
},
{
pattern: /(^|[^\\])##.*/,
lookbehind: true,
greedy: true,
alias: 'comment'
}
],
'directive': {
pattern: /(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|{[a-z][\w-]*})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,
lookbehind: true,
inside: {
keyword: {
pattern: /^#@?(?:[a-z][\w-]*|{[a-z][\w-]*})|\bin\b/,
inside: {
'punctuation': /[{}]/
}
},
rest: velocity
}
},
'variable': velocity['variable']
});
Prism.languages.velocity['tag'].inside['attr-value'].inside.rest = Prism.languages.velocity;
}(Prism));

1
components/prism-velocity.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e.languages.velocity=e.languages.extend("markup",{});var n={variable:{pattern:/(^|[^\\](?:\\\\)*)\$!?(?:[a-z][\w-]*(?:\([^)]*\))?(?:\.[a-z][\w-]*(?:\([^)]*\))?|\[[^\]]+])*|{[^}]+})/i,lookbehind:!0,inside:{}},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},number:/\b\d+\b/,"boolean":/\b(?:true|false)\b/,operator:/[=!<>]=?|[+*\/%-]|&&|\|\||\.\.|\b(?:eq|g[et]|l[et]|n(?:e|ot))\b/,punctuation:/[(){}[\]:,.]/};n.variable.inside={string:n.string,"function":{pattern:/([^\w-])[a-z][\w-]*(?=\()/,lookbehind:!0},number:n.number,"boolean":n["boolean"],punctuation:n.punctuation},e.languages.insertBefore("velocity","comment",{unparsed:{pattern:/(^|[^\\])#\[\[[\s\S]*?]]#/,lookbehind:!0,greedy:!0,inside:{punctuation:/^#\[\[|]]#$/}},"velocity-comment":[{pattern:/(^|[^\\])#\*[\s\S]*?\*#/,lookbehind:!0,greedy:!0,alias:"comment"},{pattern:/(^|[^\\])##.*/,lookbehind:!0,greedy:!0,alias:"comment"}],directive:{pattern:/(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|{[a-z][\w-]*})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,lookbehind:!0,inside:{keyword:{pattern:/^#@?(?:[a-z][\w-]*|{[a-z][\w-]*})|\bin\b/,inside:{punctuation:/[{}]/}},rest:n}},variable:n.variable}),e.languages.velocity.tag.inside["attr-value"].inside.rest=e.languages.velocity}(Prism);

View File

@ -0,0 +1,47 @@
<h2>Comments</h2>
<pre><code>## Single line comment
#* Multi-line
comment *#</code></pre>
<h2>Unparsed sections</h2>
<pre><code>## Section below is not parsed
#[[
## This is not a comment
]]#</code></pre>
<h2>Variables</h2>
<pre><code>$mud
$customer.Name
$flogger.getPromo( $mud )
$!{mudSlinger_9}
$foo[0]
$foo[$i]
$foo["bar"]
$foo.bar[1].junk
$foo.callMethod()[1]</code></pre>
<h2>Directives</h2>
<pre><code>#set($foo.bar[1] = 3)
#if($a==1)true enough#{else}no way!#end
#macro( d )
&lt;tr>&lt;td>$!bodyContent&lt;/td>&lt;/tr>
#end
#@d()Hello!#end</code></pre>
<h2>Integration with HTML</h2>
<pre><code>&lt;html>
&lt;body>
Hello $customer.Name!
&lt;table>
#foreach( $mud in $mudsOnSpecial )
#if ( $customer.hasPurchased($mud) )
&lt;tr>
&lt;td>
$flogger.getPromo( $mud )
&lt;/td>
&lt;/tr>
#end
#end
&lt;/table>
&lt;/body>
&lt;/html></code></pre>

View File

@ -4,7 +4,7 @@
}
// The dependencies map is built automatically with gulp
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","wiki":"markup","xeora":"markup"}/*]*/;
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","velocity":"markup","wiki":"markup","xeora":"markup"}/*]*/;
var lang_data = {};

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup",erb:["ruby","markup-templating"],fsharp:"clike",flow:"javascript",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",jolie:"clike",kotlin:"clike",less:"css",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:"javascript",qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup-templating",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",vbnet:"basic",wiki:"markup",xeora:"markup"},a={},c="none",t=document.getElementsByTagName("script");t=t[t.length-1];var r="components/";if(t.hasAttribute("data-autoloader-path")){var s=t.getAttribute("data-autoloader-path").trim();s.length>0&&!/^[a-z]+:\/\//i.test(t.src)&&(r=s.replace(/\/?$/,"/"))}else/[\w-]+\.js$/.test(t.src)&&(r=t.src.replace(/[\w-]+\.js$/,"components/"));var n=Prism.plugins.autoloader={languages_path:r,use_minified:!0},t=function(e,a,c){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),c&&c()},document.body.appendChild(t)},i=function(e){return n.languages_path+"prism-"+e+(n.use_minified?".min":"")+".js"},l=function(e,c){var t=a[e];t||(t=a[e]={});var r=c.getAttribute("data-dependencies");!r&&c.parentNode&&"pre"===c.parentNode.tagName.toLowerCase()&&(r=c.parentNode.getAttribute("data-dependencies")),r=r?r.split(/\s*,\s*/g):[],o(r,function(){p(e,function(){Prism.highlightElement(c)})})},o=function(e,a,c){"string"==typeof e&&(e=[e]);var t=0,r=e.length,s=function(){r>t?p(e[t],function(){t++,s()},function(){c&&c(e[t])}):t===r&&a&&a(e)};s()},p=function(c,r,s){var n=function(){var e=!1;c.indexOf("!")>=0&&(e=!0,c=c.replace("!",""));var n=a[c];if(n||(n=a[c]={}),r&&(n.success_callbacks||(n.success_callbacks=[]),n.success_callbacks.push(r)),s&&(n.error_callbacks||(n.error_callbacks=[]),n.error_callbacks.push(s)),!e&&Prism.languages[c])u(c);else if(!e&&n.error)m(c);else if(e||!n.loading){n.loading=!0;var l=i(c);t(l,function(){n.loading=!1,u(c)},function(){n.loading=!1,n.error=!0,m(c)})}},l=e[c];l&&l.length?o(l,n):n()},u=function(e){a[e]&&a[e].success_callbacks&&a[e].success_callbacks.length&&a[e].success_callbacks.forEach(function(a){a(e)})},m=function(e){a[e]&&a[e].error_callbacks&&a[e].error_callbacks.length&&a[e].error_callbacks.forEach(function(a){a(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&e.language!==c&&l(e.language,e.element)})}}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup",erb:["ruby","markup-templating"],fsharp:"clike",flow:"javascript",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",jolie:"clike",kotlin:"clike",less:"css",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:"javascript",qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup-templating",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup"},a={},c="none",t=document.getElementsByTagName("script");t=t[t.length-1];var r="components/";if(t.hasAttribute("data-autoloader-path")){var s=t.getAttribute("data-autoloader-path").trim();s.length>0&&!/^[a-z]+:\/\//i.test(t.src)&&(r=s.replace(/\/?$/,"/"))}else/[\w-]+\.js$/.test(t.src)&&(r=t.src.replace(/[\w-]+\.js$/,"components/"));var n=Prism.plugins.autoloader={languages_path:r,use_minified:!0},t=function(e,a,c){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),c&&c()},document.body.appendChild(t)},i=function(e){return n.languages_path+"prism-"+e+(n.use_minified?".min":"")+".js"},l=function(e,c){var t=a[e];t||(t=a[e]={});var r=c.getAttribute("data-dependencies");!r&&c.parentNode&&"pre"===c.parentNode.tagName.toLowerCase()&&(r=c.parentNode.getAttribute("data-dependencies")),r=r?r.split(/\s*,\s*/g):[],o(r,function(){p(e,function(){Prism.highlightElement(c)})})},o=function(e,a,c){"string"==typeof e&&(e=[e]);var t=0,r=e.length,s=function(){r>t?p(e[t],function(){t++,s()},function(){c&&c(e[t])}):t===r&&a&&a(e)};s()},p=function(c,r,s){var n=function(){var e=!1;c.indexOf("!")>=0&&(e=!0,c=c.replace("!",""));var n=a[c];if(n||(n=a[c]={}),r&&(n.success_callbacks||(n.success_callbacks=[]),n.success_callbacks.push(r)),s&&(n.error_callbacks||(n.error_callbacks=[]),n.error_callbacks.push(s)),!e&&Prism.languages[c])u(c);else if(!e&&n.error)m(c);else if(e||!n.loading){n.loading=!0;var l=i(c);t(l,function(){n.loading=!1,u(c)},function(){n.loading=!1,n.error=!0,m(c)})}},l=e[c];l&&l.length?o(l,n):n()},u=function(e){a[e]&&a[e].success_callbacks&&a[e].success_callbacks.length&&a[e].success_callbacks.forEach(function(a){a(e)})},m=function(e){a[e]&&a[e].error_callbacks&&a[e].error_callbacks.length&&a[e].error_callbacks.forEach(function(a){a(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&e.language!==c&&l(e.language,e.element)})}}();

View File

@ -0,0 +1,417 @@
#foreach($mud in $mudsOnSpecial)
#if($customer.hasPurchased($mud))
#set($a = "Velocity")
#set($foo.bar[1] = 3)
#{set}($map["apple"] = "orange")
#if($foo == $bar)#end
#if (!$foo)#end
#if ($foo && $foo.bar)#end
#{if}($foo1 || $foo2)#end
#set( $monkey.Say = ["Not", $my, "fault"] )
#set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"})
#set( $result = $query.criteria("address") )
#set( $result = true )
#set( $result = false )
#if( $foo < 10 )
#elseif( $foo == 10 )
#else
#end
#if( $foo == $bar)it's true!#{else}it's not!#end
#include( "greetings.txt", $seasonalstock )
#parse( "me.vm" )
#{parse}( "me.vm" )
#break
#{break}
#break($macro.topmost)
#stop('$foo was not in context')
#{stop}
#evaluate($dynamicsource)
#macro( d )
<tr><td></td></tr>
#end
#d()
#@d()Hello!#end
\#include( "a.txt" )
\\#include ( "a.txt" )
#set($foo=["$10 and ","a pie"])#foreach($a in $foo)$a#end
#set( $foo = $bar + 3 )
#set( $foo = $bar - 4 )
#set( $foo = $bar * 6 )
#set( $foo = $bar / 2 )
#set( $foo = $bar % 5 )
#foreach( $foo in [1..5] )
----------------------------------------------------
[
["directive", [
["keyword", ["#foreach"]],
["punctuation", "("],
["variable", ["$mud"]],
["keyword", ["in"]],
["variable", ["$mudsOnSpecial"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["variable", [
"$customer",
["punctuation", "."],
["function", "hasPurchased"],
["punctuation", "("],
"$mud",
["punctuation", ")"]
]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$a"]],
["operator", "="],
["string", "\"Velocity\""],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", [
"$foo",
["punctuation", "."],
"bar",
["punctuation", "["],
["number", "1"],
["punctuation", "]"]
]],
["operator", "="],
["number", "3"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#", ["punctuation", "{"], "set", ["punctuation", "}"]]],
["punctuation", "("],
["variable", [
"$map",
["punctuation", "["],
["string", "\"apple\""],
["punctuation", "]"]
]],
["operator", "="],
["string", "\"orange\""],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "=="],
["variable", ["$bar"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["operator", "!"],
["variable", ["$foo"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "&&"],
["variable", ["$foo", ["punctuation", "."], "bar"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#", ["punctuation", "{"], "if", ["punctuation", "}"]]],
["punctuation", "("],
["variable", ["$foo1"]],
["operator", "||"],
["variable", ["$foo2"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$monkey", ["punctuation", "."], "Say"]],
["operator", "="],
["punctuation", "["],
["string", "\"Not\""],
["punctuation", ","],
["variable", ["$my"]],
["punctuation", ","],
["string", "\"fault\""],
["punctuation", "]"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$monkey", ["punctuation", "."], "Map"]],
["operator", "="],
["punctuation", "{"],
["string", "\"banana\""],
["punctuation", ":"],
["string", "\"good\""],
["punctuation", ","],
["string", "\"roast beef\""],
["punctuation", ":"],
["string", "\"bad\""],
["punctuation", "}"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$result"]],
["operator", "="],
["variable", [
"$query",
["punctuation", "."],
["function", "criteria"],
["punctuation", "("],
["string", "\"address\""],
["punctuation", ")"]
]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$result"]],
["operator", "="],
["boolean", "true"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$result"]],
["operator", "="],
["boolean", "false"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "<"],
["number", "10"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#elseif"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "=="],
["number", "10"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#else"]]
]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#if"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "=="],
["variable", ["$bar"]],
["punctuation", ")"]
]],
"it's true!",
["directive", [
["keyword", ["#", ["punctuation", "{"], "else", ["punctuation", "}"]]]
]],
"it's not!",
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#include"]],
["punctuation", "("],
["string", "\"greetings.txt\""],
["punctuation", ","],
["variable", ["$seasonalstock"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#parse"]],
["punctuation", "("],
["string", "\"me.vm\""],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#", ["punctuation", "{"], "parse", ["punctuation", "}"]]],
["punctuation", "("],
["string", "\"me.vm\""],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#break"]]
]],
["directive", [
["keyword", ["#", ["punctuation", "{"], "break", ["punctuation", "}"]]]
]],
["directive", [
["keyword", ["#break"]],
["punctuation", "("],
["variable", ["$macro", ["punctuation", "."], "topmost"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#stop"]],
["punctuation", "("],
["string", "'$foo was not in context'"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#", ["punctuation", "{"], "stop", ["punctuation", "}"]]]
]],
["directive", [
["keyword", ["#evaluate"]],
["punctuation", "("],
["variable", ["$dynamicsource"]],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#macro"]],
["punctuation", "("],
" d ",
["punctuation", ")"]
]],
["tag", [["tag", [["punctuation", "<"], "tr"]], ["punctuation", ">"]]],
["tag", [["tag", [["punctuation", "<"], "td"]], ["punctuation", ">"]]],
["tag", [["tag", [["punctuation", "</"], "td"]], ["punctuation", ">"]]],
["tag", [["tag", [["punctuation", "</"], "tr"]], ["punctuation", ">"]]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#d"]],
["punctuation", "("],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#@d"]],
["punctuation", "("],
["punctuation", ")"]
]],
"Hello!",
["directive", [
["keyword", ["#end"]]
]],
"\r\n\\#include( \"a.txt\" )\r\n\\\\",
["directive", [
["keyword", ["#include"]],
["punctuation", "("],
["string", "\"a.txt\""],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["punctuation", "["],
["string", "\"$10 and \""],
["punctuation", ","],
["string", "\"a pie\""],
["punctuation", "]"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#foreach"]],
["punctuation", "("],
["variable", ["$a"]],
["keyword", ["in"]],
["variable", ["$foo"]],
["punctuation", ")"]
]],
["variable", ["$a"]],
["directive", [
["keyword", ["#end"]]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["variable", ["$bar"]],
["operator", "+"],
["number", "3"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["variable", ["$bar"]],
["operator", "-"],
["number", "4"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["variable", ["$bar"]],
["operator", "*"],
["number", "6"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["variable", ["$bar"]],
["operator", "/"],
["number", "2"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#set"]],
["punctuation", "("],
["variable", ["$foo"]],
["operator", "="],
["variable", ["$bar"]],
["operator", "%"],
["number", "5"],
["punctuation", ")"]
]],
["directive", [
["keyword", ["#foreach"]],
["punctuation", "("],
["variable", ["$foo"]],
["keyword", ["in"]],
["punctuation", "["],
["number", "1"],
["operator", ".."],
["number", "5"],
["punctuation", "]"],
["punctuation", ")"]
]]
]
----------------------------------------------------
Checks for directives.

View File

@ -0,0 +1,29 @@
#[[]]#
#[[This is not parsed]]#
#[[#if("some quotes" 'some quotes')
## #* *#
$dollar
]]#
----------------------------------------------------
[
["unparsed", [
["punctuation", "#[["],
["punctuation", "]]#"]
]],
["unparsed", [
["punctuation", "#[["],
"This is not parsed",
["punctuation", "]]#"]
]],
["unparsed", [
["punctuation", "#[["],
"#if(\"some quotes\" 'some quotes')\r\n## #* *#\r\n$dollar\r\n",
["punctuation", "]]#"]
]]
]
----------------------------------------------------
Checks for unparsed sections.

View File

@ -0,0 +1,147 @@
$mud
$customer.Name
$flogger.getPromo( $mud )
$mud-slinger
$mud_slinger
$mudSlinger1
$!mudSlinger_9
$person.setAttributes( ["Strange", false, "Excited"] )
$foo[0]
$foo[$i]
$foo["bar"]
$foo.bar[1].junk
$foo.callMethod()[1]
$foo["apple"][4]
${mudSlinger}
$!{mudSlinger_9}
${customer.Address}
${purchase.getTotal()}
<input value="$email"/>
<input value="$!{email}"/>
$\!foo
$\!{foo}
$\\!foo
$\\\!foo
\$foo
\$!foo
\$!{foo}
\\$!{foo}
----------------------------------------------------
[
["variable", ["$mud"]],
["variable", ["$customer", ["punctuation", "."], "Name"]],
["variable", [
"$flogger",
["punctuation", "."],
["function", "getPromo"],
["punctuation", "("],
" $mud ",
["punctuation", ")"]
]],
["variable", ["$mud-slinger"]],
["variable", ["$mud_slinger"]],
["variable", ["$mudSlinger1"]],
["variable", ["$!mudSlinger_9"]],
["variable", [
"$person",
["punctuation", "."],
["function", "setAttributes"],
["punctuation", "("],
["punctuation", "["],
["string", "\"Strange\""],
["punctuation", ","],
["boolean", "false"],
["punctuation", ","],
["string", "\"Excited\""],
["punctuation", "]"],
["punctuation", ")"]
]],
["variable", ["$foo", ["punctuation", "["], ["number", "0"], ["punctuation", "]"]]],
["variable", ["$foo", ["punctuation", "["], "$i", ["punctuation", "]"]]],
["variable", ["$foo", ["punctuation", "["], ["string", "\"bar\""], ["punctuation", "]"]]],
["variable", [
"$foo",
["punctuation", "."],
"bar",
["punctuation", "["],
["number", "1"],
["punctuation", "]"],
["punctuation", "."],
"junk"
]],
["variable", [
"$foo",
["punctuation", "."],
["function", "callMethod"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "["],
["number", "1"],
["punctuation", "]"]
]],
["variable", [
"$foo",
["punctuation", "["],
["string", "\"apple\""],
["punctuation", "]"],
["punctuation", "["],
["number", "4"],
["punctuation", "]"]
]],
["variable", ["$", ["punctuation", "{"], "mudSlinger", ["punctuation", "}"]]],
["variable", ["$!", ["punctuation", "{"], "mudSlinger_9", ["punctuation", "}"]]],
["variable", [
"$",
["punctuation", "{"],
"customer",
["punctuation", "."],
"Address",
["punctuation", "}"]
]],
["variable", [
"$",
["punctuation", "{"],
"purchase",
["punctuation", "."],
["function", "getTotal"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "}"]
]],
["tag", [
["tag", [
["punctuation", "<"],
"input"
]],
["attr-name", ["value"]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
["variable", ["$email"]],
["punctuation", "\""]
]],
["punctuation", "/>"]
]],
["tag", [
["tag", [
["punctuation", "<"],
"input"
]],
["attr-name", ["value"]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
["variable", ["$!", ["punctuation", "{"], "email", ["punctuation", "}"]]],
["punctuation", "\""]
]],
["punctuation", "/>"]
]],
"\r\n$\\!foo\r\n$\\!{foo}\r\n$\\\\!foo\r\n$\\\\\\!foo\r\n\\$foo\r\n\\$!foo\r\n\\$!{foo}\r\n\\\\",
["variable", ["$!", ["punctuation", "{"], "foo", ["punctuation", "}"]]]
]
----------------------------------------------------
Checks for variables.

View File

@ -0,0 +1,18 @@
#**#
#*Multiline <div>
comment*#
##
## Single line comment <div>
----------------------------------------------------
[
["velocity-comment", "#**#"],
["velocity-comment", "#*Multiline <div>\r\ncomment*#"],
["velocity-comment", "##"],
["velocity-comment", "## Single line comment <div>"]
]
----------------------------------------------------
Checks for comments.