Created
February 23, 2012 18:48
-
-
Save guillaumebort/1894297 to your computer and use it in GitHub Desktop.
Play scala templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ scopeName = 'text.html.scala'; | |
fileTypes = ( 'scala.html' ); | |
foldingStartMarker = '(?x) | |
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?> | |
|<!--(?!.*-->) | |
|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/))) | |
)'; | |
foldingStopMarker = '(?x) | |
(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)> | |
|^\s*--> | |
|(^|\s)\} | |
)'; | |
patterns = ( | |
{ include = '#header'; }, | |
{ include = '#html'; }, | |
{ begin = '(?=[^@]|@[^(])'; | |
end = '----EOF----'; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
); | |
repository = { | |
block = { | |
patterns = ( | |
{ begin = '(?=@[a-zA-Z_]+[a-zA-Z0-9_]*([.][a-zA-Z_][a-zA-Z0-9_]*|\(.*\))*\s*=?\s*@?\{)'; | |
end = '(?<=\})'; | |
patterns = ( | |
{ include = '#expression'; }, | |
{ include = '#scala-block'; }, | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
match = '(?<=\{).*=>'; | |
}, | |
{ include = '#template-content'; }, | |
); | |
}, | |
{ name = 'source.scala.embedded'; | |
match = '\s|='; | |
}, | |
); | |
}, | |
); | |
}; | |
block-continuation = { | |
patterns = ( | |
{ begin = '(?<=\})( )(?=\s*\{)'; | |
end = '(?<=\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
); | |
}, | |
); | |
}; | |
call-block-continuation = { | |
patterns = ( | |
{ begin = '(?<=\})[.](?=[a-zA-Z]+[a-zA-Z0-9]*([.][a-zA-Z][a-zA-Z0-9]*|\(.*\))*\s*=?\s*@?\{)'; | |
end = '(?<=\})'; | |
patterns = ( | |
{ begin = '(?<=[.])'; | |
end = ' '; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
match = '(?<=\{).*=>'; | |
}, | |
{ include = '#template-content'; }, | |
); | |
}, | |
); | |
}, | |
); | |
}; | |
call-continuation = { | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(?<=\})[.](?=[a-zA-Z])'; | |
end = '(?=([^a-zA-Z0-9._(]|((?<=[)])[a-zA-Z0-9_])|([.](?![a-zA-Z]))))'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
case-expression = { | |
patterns = ( | |
{ begin = '(?=case.*=>\s*\{)'; | |
end = '(?<=\})'; | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(?=case)'; | |
end = '(?={)'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
); | |
}, | |
); | |
}; | |
dynamic-parts = { | |
patterns = ( | |
{ include = '#scala-comment'; }, | |
{ include = '#match-expression'; }, | |
{ include = '#case-expression'; }, | |
{ include = '#simple-brackets'; }, | |
{ include = '#escaped-at'; }, | |
{ include = '#block'; }, | |
{ include = '#scala-block'; }, | |
{ include = '#call-block-continuation'; }, | |
{ include = '#call-continuation'; }, | |
{ include = '#else-continuation'; }, | |
{ include = '#block-continuation'; }, | |
{ include = '#expression'; }, | |
{ include = '#safe-expression'; }, | |
{ include = '#invalid-expression'; }, | |
); | |
}; | |
else-continuation = { | |
patterns = ( | |
{ begin = '(?<=\})( )(?=\s*else\s*\{)'; | |
end = '(?<=\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
{ name = 'source.scala.embedded'; | |
begin = '(?<=\} )'; | |
end = '(?=\{)'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}, | |
); | |
}; | |
embedded-code = { patterns = ( { include = '#dynamic-parts'; } ); }; | |
embedded-scala = { | |
patterns = ( | |
{ name = 'text.html.scala.code'; | |
begin = '\{'; | |
end = '\}'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
{ name = 'text.html.scala.code'; | |
begin = '\('; | |
end = '\)'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
{ include = 'source.scala'; }, | |
); | |
}; | |
entities = { | |
patterns = ( | |
{ name = 'constant.character.entity.html'; | |
match = '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)'; | |
captures = { | |
1 = { name = 'punctuation.definition.entity.html'; }; | |
3 = { name = 'punctuation.definition.entity.html'; }; | |
}; | |
}, | |
{ name = 'invalid.illegal.bad-ampersand.html'; | |
match = '&'; | |
}, | |
); | |
}; | |
escaped-at = { | |
patterns = ( | |
{ name = 'markup.italic'; | |
match = '@@'; | |
}, | |
); | |
}; | |
expression = { | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(@)(?=[a-zA-Z_])'; | |
end = '(?=([^a-zA-Z0-9._(\[\]]|((?<=[)])[a-zA-Z0-9_])|([.](?![a-zA-Z_]))))'; | |
beginCaptures = { 1 = { name = 'variable.other.play'; }; }; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
header = { | |
patterns = ( | |
{ name = 'markup.heading'; | |
begin = '(@)(?=\()'; | |
end = '\s'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
html = { | |
patterns = ( | |
{ name = 'meta.tag.any.html'; | |
begin = '(<)([a-zA-Z0-9:]++)(?=[^>]*></\2>)'; | |
end = '(>(<)/)(\2)(>)'; | |
beginCaptures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.html'; }; | |
}; | |
endCaptures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'meta.scope.between-tag-pair.html'; }; | |
3 = { name = 'entity.name.tag.html'; }; | |
4 = { name = 'punctuation.definition.tag.html'; }; | |
}; | |
patterns = ( { include = '#tag-stuff'; } ); | |
}, | |
{ name = 'meta.tag.preprocessor.xml.html'; | |
begin = '(<\?)(xml)'; | |
end = '(\?>)'; | |
captures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.xml.html'; }; | |
}; | |
patterns = ( | |
{ include = '#tag-generic-attribute'; }, | |
{ include = '#string-double-quoted'; }, | |
{ include = '#string-single-quoted'; }, | |
); | |
}, | |
{ name = 'comment.block.html'; | |
begin = '<!--'; | |
end = '--\s*>'; | |
captures = { 0 = { name = 'punctuation.definition.comment.html'; }; }; | |
patterns = ( | |
{ name = 'invalid.illegal.bad-comments-or-CDATA.html'; | |
match = '--'; | |
}, | |
{ include = '#embedded-code'; }, | |
); | |
}, | |
{ name = 'meta.tag.sgml.html'; | |
begin = '<!'; | |
end = '>'; | |
captures = { 0 = { name = 'punctuation.definition.tag.html'; }; }; | |
patterns = ( | |
{ name = 'meta.tag.sgml.doctype.html'; | |
begin = '(DOCTYPE)'; | |
end = '(?=>)'; | |
captures = { 1 = { name = 'entity.name.tag.doctype.html'; }; }; | |
patterns = ( | |
{ name = 'string.quoted.double.doctype.identifiers-and-DTDs.html'; | |
match = '"[^">]*"'; | |
}, | |
); | |
}, | |
{ name = 'constant.other.inline-data.html'; | |
begin = '\[CDATA\['; | |
end = ']](?=>)'; | |
}, | |
{ name = 'invalid.illegal.bad-comments-or-CDATA.html'; | |
match = '(\s*)(?!--|>)\S(\s*)'; | |
}, | |
); | |
}, | |
{ include = '#embedded-code'; }, | |
{ name = 'source.css.embedded.html'; | |
begin = '(?:^\s+)?(<)((?i:style))\b(?![^>]*/>)'; | |
end = '(</)((?i:style))(>)(?:\s*\n)?'; | |
captures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.style.html'; }; | |
3 = { name = 'punctuation.definition.tag.html'; }; | |
}; | |
patterns = ( | |
{ include = '#tag-stuff'; }, | |
{ begin = '(>)'; | |
end = '(?=</(?i:style))'; | |
beginCaptures = { 1 = { name = 'punctuation.definition.tag.html'; }; }; | |
patterns = ( { include = 'source.css'; } ); | |
}, | |
); | |
}, | |
{ name = 'source.js.embedded.html'; | |
begin = '(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)'; | |
end = '(?<=</(script|SCRIPT))(>)(?:\s*\n)?'; | |
beginCaptures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.script.html'; }; | |
}; | |
endCaptures = { 2 = { name = 'punctuation.definition.tag.html'; }; }; | |
patterns = ( | |
{ include = '#tag-stuff'; }, | |
{ begin = '(?<!</(?:script|SCRIPT))(>)'; | |
end = '(</)((?i:script))'; | |
captures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.script.html'; }; | |
}; | |
patterns = ( | |
{ name = 'comment.line.double-slash.js'; | |
match = '(//).*?((?=</script)|$\n?)'; | |
captures = { 1 = { name = 'punctuation.definition.comment.js'; }; }; | |
}, | |
{ name = 'comment.block.js'; | |
begin = '/\*'; | |
end = '\*/|(?=</script)'; | |
captures = { 0 = { name = 'punctuation.definition.comment.js'; }; }; | |
}, | |
{ include = 'source.js'; }, | |
); | |
}, | |
); | |
}, | |
{ name = 'meta.tag.structure.any.html'; | |
begin = '(</?)((?i:body|head|html)\b)'; | |
end = '(>)'; | |
captures = { | |
1 = { name = 'punctuation.definition.tag.html'; }; | |
2 = { name = 'entity.name.tag.structure.any.html'; }; | |
}; | |
patterns = ( { include = '#tag-stuff'; } ); | |
}, | |
{ name = 'meta.tag.block.any.html'; | |
begin = '(</?)((?i:address|blockquote|dd|div|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)'; | |
end = '(>)'; | |
beginCaptures = { | |
1 = { name = 'punctuation.definition.tag.begin.html'; }; | |
2 = { name = 'entity.name.tag.block.any.html'; }; | |
}; | |
endCaptures = { 1 = { name = 'punctuation.definition.tag.end.html'; }; }; | |
patterns = ( { include = '#tag-stuff'; } ); | |
}, | |
{ name = 'meta.tag.inline.any.html'; | |
begin = '(</?)((?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)'; | |
end = '((?: ?/)?>)'; | |
beginCaptures = { | |
1 = { name = 'punctuation.definition.tag.begin.html'; }; | |
2 = { name = 'entity.name.tag.inline.any.html'; }; | |
}; | |
endCaptures = { 1 = { name = 'punctuation.definition.tag.end.html'; }; }; | |
patterns = ( { include = '#tag-stuff'; } ); | |
}, | |
{ name = 'meta.tag.other.html'; | |
begin = '(</?)([a-zA-Z0-9:]+)'; | |
end = '(>)'; | |
beginCaptures = { | |
1 = { name = 'punctuation.definition.tag.begin.html'; }; | |
2 = { name = 'entity.name.tag.other.html'; }; | |
}; | |
endCaptures = { 1 = { name = 'punctuation.definition.tag.end.html'; }; }; | |
patterns = ( { include = '#tag-stuff'; } ); | |
}, | |
{ include = '#entities'; }, | |
{ name = 'invalid.illegal.incomplete.html'; | |
match = '<>'; | |
}, | |
{ name = 'invalid.illegal.bad-angle-bracket.html'; | |
match = '<'; | |
}, | |
); | |
}; | |
invalid-expression = { | |
patterns = ( | |
{ name = 'meta.line.error.logfile'; | |
match = '@[^a-zA-Z]'; | |
}, | |
); | |
}; | |
match-expression = { | |
patterns = ( | |
{ begin = '(?=@[a-zA-Z][a-zA-Z_0-9]*\s+match\s*\{)'; | |
end = '(?<=\})'; | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
match = '(@)'; | |
captures = { 1 = { name = 'variable.other.play'; }; }; | |
}, | |
{ name = 'source.scala.embedded'; | |
begin = '(?=[a-zA-Z])'; | |
end = '(?={)'; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
{ begin = '(\{)'; | |
end = '(\})'; | |
beginCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
endCaptures = { 1 = { name = 'source.scala.embedded'; }; }; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
); | |
}, | |
); | |
}; | |
safe-expression = { | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(@)\('; | |
end = '\)'; | |
beginCaptures = { 1 = { name = 'variable.other.play'; }; }; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
scala-block = { | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(@)\{'; | |
end = '\}'; | |
beginCaptures = { 1 = { name = 'markup.bold'; }; }; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
scala-comment = { | |
patterns = ( | |
{ name = 'comment.block.html'; | |
begin = '@[*]'; | |
end = '[*]@'; | |
}, | |
); | |
}; | |
scala-import = { | |
patterns = ( | |
{ name = 'source.scala.embedded'; | |
begin = '(@)(import)'; | |
end = '$'; | |
beginCaptures = { | |
1 = { name = 'variable.other.play'; }; | |
2 = { name = 'keyword.declaration.scala'; }; | |
}; | |
patterns = ( { include = '#embedded-scala'; } ); | |
}, | |
); | |
}; | |
simple-brackets = { | |
patterns = ( | |
{ begin = '\{'; | |
end = '\}[.| ]?'; | |
patterns = ( { include = '#template-content'; } ); | |
}, | |
); | |
}; | |
string-double-quoted = { | |
name = 'string.quoted.double.html'; | |
begin = '"'; | |
end = '"'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.html'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.html'; }; }; | |
patterns = ( | |
{ include = '#embedded-code'; }, | |
{ include = '#entities'; }, | |
); | |
}; | |
string-single-quoted = { | |
name = 'string.quoted.single.html'; | |
begin = "'"; | |
end = "'"; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.html'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.html'; }; }; | |
patterns = ( | |
{ include = '#embedded-code'; }, | |
{ include = '#entities'; }, | |
); | |
}; | |
tag-generic-attribute = { | |
name = 'entity.other.attribute-name.html'; | |
match = '\b([a-zA-Z\-:]+)'; | |
}; | |
tag-id-attribute = { | |
name = 'meta.attribute-with-value.id.html'; | |
begin = '\b(id)\b\s*(=)'; | |
end = '(?<=''|")'; | |
captures = { | |
1 = { name = 'entity.other.attribute-name.id.html'; }; | |
2 = { name = 'punctuation.separator.key-value.html'; }; | |
}; | |
patterns = ( | |
{ name = 'string.quoted.double.html'; | |
contentName = 'meta.toc-list.id.html'; | |
begin = '"'; | |
end = '"'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.html'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.html'; }; }; | |
patterns = ( | |
{ include = '#embedded-code'; }, | |
{ include = '#entities'; }, | |
); | |
}, | |
{ name = 'string.quoted.single.html'; | |
contentName = 'meta.toc-list.id.html'; | |
begin = "'"; | |
end = "'"; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.html'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.html'; }; }; | |
patterns = ( | |
{ include = '#embedded-code'; }, | |
{ include = '#entities'; }, | |
); | |
}, | |
); | |
}; | |
tag-stuff = { | |
patterns = ( | |
{ include = '#tag-id-attribute'; }, | |
{ include = '#tag-generic-attribute'; }, | |
{ include = '#string-double-quoted'; }, | |
{ include = '#string-single-quoted'; }, | |
{ include = '#embedded-code'; }, | |
); | |
}; | |
template-content = { | |
patterns = ( | |
{ include = '#scala-comment'; }, | |
{ include = '#match-expression'; }, | |
{ include = '#case-expression'; }, | |
{ include = '#simple-brackets'; }, | |
{ include = '#escaped-at'; }, | |
{ include = '#scala-import'; }, | |
{ include = '#block'; }, | |
{ include = '#scala-block'; }, | |
{ include = '#call-block-continuation'; }, | |
{ include = '#call-continuation'; }, | |
{ include = '#else-continuation'; }, | |
{ include = '#block-continuation'; }, | |
{ include = '#expression'; }, | |
{ include = '#safe-expression'; }, | |
{ include = '#invalid-expression'; }, | |
{ include = '#html'; }, | |
); | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment