Skip to content

Instantly share code, notes, and snippets.

@joshheartsy
Forked from hmcfletch/gist:1018085
Created July 1, 2011 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshheartsy/1059468 to your computer and use it in GitHub Desktop.
Save joshheartsy/1059468 to your computer and use it in GitHub Desktop.
TextMate javascript syntax highlighting for content_for :inline_js
// To edit:
// Bundles -> Bundle Editor -> Edit Languages
// Open Ruby on Rails
// Edit HTML (Rails)
// add to the patterns
// works for <% content_for :inline_js do -%>
// can prefix :inline_js like :fb_inline_js
// The end tag should contain <% end #end :inline_js %>
{
name = 'inline_js.rails.embedded.html';
begin = '<%\s*(content_for)\s+(:.*inline_js)\s+(do)\s*-?%>';
end = '<%\s*(end)\s*(\#(end|END) :.*inline_js\s*-?%>\s*)';
beginCaptures = {
1 = { name = 'support.function.viewhelpers.rails'; };
2 = { name = 'constant.other.symbol.double-quoted.ruby'; };
3 = { name = 'keyword.control.def.ruby'; };
};
endCaptures = {
1 = { name = 'keyword.control.def.ruby'; };
2 = { name = 'comment.block.erb'; };
};
patterns = (
{ include = 'source.js'; }
);
}
// Snippet to make this easier (ijs + tab key)
// To create in textmate:
// Bundles -> Bundle Editor
// Add Snippet
// Activation -> choose "Tab Trigger"
// Choose a trigger, I used "ijs"
<% content_for :inline_js do %>
${1:\$(document).ready(function(){
${0:$TM_SELECTED_TEXT}
\});}
<% end #end :inline_js %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment