[TxMt] New Language for Bundle

Allan Odgaard allan at macromates.com
Thu Aug 25 07:06:56 UTC 2005


On 25/08/2005, at 8.40, Chris Ruzin wrote:

> [...] What I'm wanting is to have EE tags folded and colorized even  
> when HTML is the language.

What you should do is include the HTML language from your EE grammar.  
That way, it will, in addition to your rules, use all the rules of  
the HTML language, and thus colorize HTML as well (see below).

> My definition is small, so I've copied it below for others to  
> critique. Keep in mind I don't know what the hell I'm doing.
>
> ---
> {   scopeName = "source.ee";

Since this is embedded in HTML (as I understand), you probably want  
to name the scope something like “text.html.ee” -- that way, all  
snippets/commands etc. which have their scope set to “text.html” will  
also work when in EE files.

>     fileTypes = ( "html", "htm", "php" );
>     foldingStartMarker = "\\{(exp:([a-zA-Z0-9:]+)|if)\\b.*?\\}";
>     foldingStopMarker = "\\{/(exp:([a-zA-Z0-9:]+)|if)\\}";
>     patterns = (
>         {   name = "constant.tag.ee";
>             begin = "\\{/?([-a-zA-Z0-9_:]+)";
>             end = "\\}";
>             captures = { 1 = { name = "entity.name.tag.html"; }; };
>             patterns = (
>                 [...]
>                 {   name = "string.single-quoted.ee";
>                     begin = "'";
>                     end = "'";
>                 },

Here you add:

                 {   include = "text.html.basic"; },

>             );
>         }
>     );
> }
> ---
>
> I defined EE tags as constants because I wanted them to stand out  
> within HTML code. If you see things I'm doing wrong (which I'm sure  
> I am), please give me some advice/tips/help.

I'd suggest two other approaches,
  1) name them source.ee.embedded instead -- there's a style which  
set the background color of source in text, and thus, the tags will  
stand out (this assumes though, that they are source),
  2) name them meta.ee-tag or something like that, and just add the  
style you want for that name in Fonts & Colors preferences.

But ultimately, the choice is of course yours! :)





More information about the textmate mailing list