About Us

Bulletpoint StarImulus® is a technology focused design + interactive agency.

In addition to our client services we also have a few products in the works. Our office is always filled with chatter and this blog is an outlet for our creative energy, rants and ideas.

Podium

StacksStacks ®
A group task management solution that finally makes sense.

Sign Up For A Free Trial »

Featured Project

Jun6

How to set up a sexy jQuery TextMate bundle

Here at Imulus we’re massive fans of jQuery. We use it on a lot of our projects. We’re also fans of TextMate, an awesome text editor produced by the folks at MacroMates. Over the last few years we’ve refined our TextMate bundles (code highlighting and language recognition packages) to work ideally within the Imulus process.

So, during my recent love affair with jQuery I’ve heavily relied on their documentation section to look up specific functions and commands. And while their documentation is awesome, it’s still a slow process. Luckily, an awesome guy named Karl Swedberg has put together a beautiful jQuery bundle for TextMate that has tons of snippets for common jQuery tasks. And, it’s free!

Installation

Head over to GitHub and grab the lastest version of the bundle. When you download it you’ll get a weird filename like this:

kswedberg-jquery-tmbundle-b0622e4f889112c37e03400a6a3e63241ab29c31.zip

Unzip the file and change the folder name (which is the same as above) to:

jquery.tmbundle

Open up TextMate and then double click the jQuery bundle file you’ve just created. Boom! The bundle is installed.

Making it work within HTML documents

By default the jQuery bundle is set to only work within .js files. However, if you’re planning on using it within HTML pages you’ll need to do another few steps of work. First, copy the following code to your clipboard:

{    name = 'source.js.jquery.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 = '#php'; },
                        {    include = 'source.js'; },
                    );
                },
            );
        },

Then open up the TextMate bundle editor and drop down the HTML arrow.

html-selection

You should now see a huge list of snippets, commands, and preferences. Located in this list is an HTML language icon, it looks like this html-icon. Once this is selected you should see a large amount of code to the right. Paste the above code directly in the following position after patterns = (

patterns-paste

That’s it, you’re done. How you can access tons of jQuery snippets and code examples directly inside TextMate.

posted in: JavaScript, creativity, jQuery, web development

This post was published on Saturday, June 6, 2009 at 6:00 am

Leave a comment


Comments

1

Jack F

July 27, 2009 at 2:58 am

Thanks so much for this!

Question, I often use jQuery in .php documents, how would I go about adding jQuery support to php files?

Thanks again,

Jack

2

Alex

December 2, 2009 at 11:29 pm

Hi! Cool JQuery bundle. I installed in but was not able to make the bundle work with html docs. Pasted the code snippet where indicated and tested the script. Everything OK but still does not execute code in html. Any ideas?

3

Anatolij

February 6, 2010 at 1:02 pm

Great, perfect :)
Must have ;)

Thanks ;)

4

Fərhad

March 4, 2010 at 3:12 am

Cool!

5

agence internet

March 4, 2010 at 3:56 am

thanks for this article. This bundle seems to be good

6

Emlak Sitesi

March 4, 2010 at 10:05 am

very cool

7

Robert G

April 17, 2010 at 9:43 am

I followed your directions and JQuery works perfectly in a .html file. However when the extension is .js the JQuery only works when I go to Bundles…JavaScript JQuery and excplicitly click on what I want to be inserted.
So for example, in a .html file I can highlight the “ready” and press control H to see the JQuery documentation, but when I do the same thing in a .js file it says “no documentation found”.
Do you have a suggestion for how to get JQuery shortcut keys to work in a .js file?

8

Jeremy

April 19, 2010 at 8:17 pm

Thanks so much

9

Bruce

April 20, 2010 at 10:11 am

Hi Robert,

I have a “jQuery (Javascript)” code highlighting option in TextMate, and this is what I use when working in JS files. After looking at the Language pack for Javascript vs. Javascript (jQuery) I think that the jQuery one brings in the regular code hitting for javascript as well a the jquery commands.

have you tried that?

Cheers, Bruce