Skip to content

Instantly share code, notes, and snippets.

@jensgro
Created December 16, 2011 18:06
Show Gist options
  • Save jensgro/1487182 to your computer and use it in GitHub Desktop.
Save jensgro/1487182 to your computer and use it in GitHub Desktop.
Make jQuery work within HTML-documents in Textmate
Inside the HTML- and the HTML5-bundle you should look for the "HTML" or "HTML5"-button and find inside the script the "pattern"-section. Paste the following code right in the beginning of this section.
Source for that trick: http://imulus.com/blog/bruce/javascript/how-to-set-up-a-sexy-jquery-textmate-bundle/
// --------------------- the code that should be copied
{ 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'; },
);
},
);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment