I am sending the patch I have created for the css language definition to the list for anyone who is interested to check out. I am also including an example of why I created it. The example saved as a .css.rb file and can be executed with cmd-R in TextMate to produce the resulting css file in the same folder.
I have tried every possible way I can think of to do this without changing the CSS language definition and don't believe it is possible. If someone can do it, I would love to learn! :)
There is a post from Allan here: http://comox.textdrive.com/pipermail/ textmate/2006-April/009943.html that says this kind of thing may be supported in 2.1 at the earliest, but for now it is not possible.
Enjoy!
Matthew
The example:
#!/usr/bin/env ruby require 'erb' css = <<HERE #css
<% width = 50 %>
#header { /* the header is twice as wide as the content */ width: <%= width * 2 %>px; }
.some_content, .some_other_content { width: <%= width %>px; }
HERE File.open(__FILE__.sub(/.rb$/, ''), "w") do |file| file.puts ERB.new(css, 0, '%<>').result end
HERE File.open(__FILE__.sub(/.rb$/, ''), "w") do |file| file.puts ERB.new(css, 0, '%<>').result end
The patch:
7d6 < { include = '#ruby'; }, 12d10 < { include = '#ruby'; }, 64d61 < { include = '#ruby'; }, 69,70c66 < patterns = ( < { include = '#ruby'; }, ---
patterns = (
73c69 < } ---
},
80d75 < { include = '#ruby'; }, 138,148d132 < ruby = < { name = 'source.ruby.embedded.css'; < begin = '<%+(?!>)=?'; < end = '%>'; < patterns = ( < { name = 'comment.line.number-sign.ruby'; < match = '#.*?(?=%>)'; < }, < { include = 'source.ruby'; }, < ); < };
HERE File.open(__FILE__.sub(/.rb$/, ''), "w") do |file| file.puts ERB.new(css, 0, '%<>').result end
HERE File.open(__FILE__.sub(/.rb$/, ''), "w") do |file| file.puts ERB.new(css, 0, '%<>').result end
Oops! Somehow I accidentally included the last 4 lines of the example twice in the last message. this should really just be there once...
Matthew