Hey guys,
I just started working with TM and its great. Given time, its going to make my work much faster.
In my company we've created a large number of custom JSP taglibs. I would like to be able to add those taglibs to the HTML bundle (or more accurately create a new bundle from the HTML bundle for this). I was trying to get my head around the language definitions and I got hopelessly lost. Is there a tutorial somewhere that I can use to figure out how to do this?
Thanks Adam
Adam: do you understand regular expressions? This isn't meant to be a dig, but it would affect the kind of advice one might offer. The language grammars aren't too complex, especially to write a small extension to a current one (eg: a HTML (JSP) extension, where you write your JSP definitions and then import the entire HTML grammar).
Not knowing JSP, I'm not sure what a "taglib" is, but I presume the complexity you're running into is in syntax-highlighting. Or are snippets an issue too?
The full documentation on macromates.com, combined with a heavy dose of "looking at other bundles", is probably the best tutorial available right now. If you've got some more specific questions, do ask, because they'll be easier to answer :)
t.
On 04/08/06, Adam van den Hoven adsmart@gmail.com wrote:
Hey guys,
I just started working with TM and its great. Given time, its going to make my work much faster.
In my company we've created a large number of custom JSP taglibs. I would like to be able to add those taglibs to the HTML bundle (or more accurately create a new bundle from the HTML bundle for this). I was trying to get my head around the language definitions and I got hopelessly lost. Is there a tutorial somewhere that I can use to figure out how to do this?
Thanks Adam
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Tom,
I do understand regular expressions. I'm far from an regex ninja but certainly above average.
A tag library is a way to simplify jsp code (depending on your point of view). Basically you hide a chunk of code behind a tag so that you can do something like:
foo:section <foo:helloworld /> </foo:section> foo:section <foo:welcome date="yyyy-mm-dd" name="LLL, FFF" /> <p>Have you built your hover car yet?</p> </foo:section>
and you might expect to have at the browser:
<div class="section section0" > <p>Hello world!</p> <p>Lovely day, isn't it?</p> </div> <div class="sections section1"> <div class="welcome"> <p>Welcome Smith, John.</p> <p>You last visited us on 2006-08-12.</p> </div> <p>Have you built your hover car yet?</p> </div>
This sort of notation can, frequently, be easier to read if you need to allow non-technical users to edit complex code driven content. It can be a lot of work to build taglibs (few people do) but we have a big dev team on our side.
My biggest worries were with the syntax highlighting, but I guess mostly its going to highlight correctly already. Maybe I'll start by duplicaing some of the very useful things HTML does (like div+tab talk about a time saver) before I ask for more help.
A
Cool. That sounds like enough to work with :)
The biggest thing to get your head around is "scope". The easiest way to explain that is that it's a bit like how CSS rules apply to html. Pres ctrl+shift+p at any point in your document, and the current scope will pop up. Often, there are several.
You've got two options: either make TextMate know that when it's inside a taglib, that's a new scope, or, alternatively, just extend HTML.
I'd suggest looking at the RHTML/Rails/Ruby/HTML grammars. What happens there is that RHTML has a tiny rule to say "if you're inside these kinds of brackets, you're in my templating langauge, and that's just Ruby/Rails" so it imports all the Ruby and Rails syntax _when it's in that scope_. And then it imports HTML's grammar on top of that :)
I don't think your grammar will be hard. If you look in the langaugse (Command-Opt-Ctrl-L) editor, you'll see you can either match lines to a regex, or to a begin/end pair. You'll be able to simply modify some HTML grammar to make it match <foo: thing> and </foo: thing> as a highlighting pair.
One thing: stick to using default scopes wherever possible - this will mean that your syntax highlighting is dependent on a user's colour settings and not special stuff you've invented.
That might sounds complex; I hope not. I dove into writing a bundle and found it not too hard once you get your head around it. The examples built into the system are excellent, and I strongly suggest checking them out.
At some point, I might write a straightforward guide to building bundles for people trying to do simple things.
Let me know how you get on,
t.
On 10/08/06, Adam van den Hoven adsmart@gmail.com wrote:
Tom,
I do understand regular expressions. I'm far from an regex ninja but certainly above average.
A tag library is a way to simplify jsp code (depending on your point of view). Basically you hide a chunk of code behind a tag so that you can do something like:
foo:section <foo:helloworld /> </foo:section> foo:section <foo:welcome date="yyyy-mm-dd" name="LLL, FFF" /> <p>Have you built your hover car yet?</p> </foo:section>
and you might expect to have at the browser:
<div class="section section0" > <p>Hello world!</p> <p>Lovely day, isn't it?</p> </div> <div class="sections section1"> <div class="welcome"> <p>Welcome Smith, John.</p> <p>You last visited us on 2006-08-12.</p> </div> <p>Have you built your hover car yet?</p> </div>
This sort of notation can, frequently, be easier to read if you need to allow non-technical users to edit complex code driven content. It can be a lot of work to build taglibs (few people do) but we have a big dev team on our side.
My biggest worries were with the syntax highlighting, but I guess mostly its going to highlight correctly already. Maybe I'll start by duplicaing some of the very useful things HTML does (like div+tab talk about a time saver) before I ask for more help.
A
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate