Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 must look like
// <!-- end :fb_inline_js--> works as well
{
name = 'inline_js.rails.embedded.html';
begin = '<%\s*(content_for)\s+(:.*inline_js)\s+(do)\s*-?%>';
end = '<%\s*(end)\s*(#\s*(end|END)\s*:.*inline_js)\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
// Edit Snippet
// Click '+' and add 'New 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 %>
@joshheartsy

This comment has been minimized.

Copy link

commented Jun 10, 2011

winning!

@hmcfletch

This comment has been minimized.

Copy link
Owner Author

commented Jun 10, 2011

Need to figure out how to not have a hack for the beginCaptures... But this works for now.

@jaygooby

This comment has been minimized.

Copy link

commented Oct 7, 2012

Great stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.