Browse files

add sass new .scss template

  • Loading branch information...
1 parent 20c01a5 commit d6e8795c619970d0cfdbf4aead0869c592c44fe6 @knb knb committed with Jul 13, 2010
Showing with 20 additions and 1 deletion.
  1. +9 −1 lib/tilt.rb
  2. +11 −0 test/tilt_sasstemplate_test.rb
View
10 lib/tilt.rb
@@ -533,11 +533,19 @@ def evaluate(scope, locals, &block)
private
def sass_options
- options.merge(:filename => eval_file, :line => line)
+ options.merge(:filename => eval_file, :line => line, :syntax => :sass)
end
end
register 'sass', SassTemplate
+ # Sass's new .scss type template implementation.
+ class ScssTemplate < SassTemplate
+ private
+ def sass_options
+ options.merge(:filename => eval_file, :line => line, :syntax => :scss)
+ end
+ end
+ register 'scss', ScssTemplate
# Lessscss template implementation. See:
# http://lesscss.org/
View
11 test/tilt_sasstemplate_test.rb
@@ -16,6 +16,17 @@ class SassTemplateTest < Test::Unit::TestCase
end
end
+ class ScssTemplateTest < Test::Unit::TestCase
+ test "is registered for '.scss' files" do
+ assert_equal Tilt::ScssTemplate, Tilt['test.scss']
+ end
+
+ test "compiles and evaluates the template on #render" do
+ template = Tilt::ScssTemplate.new { |t| "#main {\n background-color: #0000f1;\n}" }
+ assert_equal "#main {\n background-color: #0000f1; }\n", template.render
+ end
+ end
+
rescue LoadError => boom
warn "Tilt::SassTemplate (disabled)\n"
end

2 comments on commit d6e8795

@benschwarz

Awesome!
I was just going batshit in my head over why this wasn't already working in Sinatra. Furious hardcore forking action was coming.

Happiness.
Double rainbow.

@benschwarz

I left my extension as sass and added Sass::Plugin.options[:syntax] = :scss (it didn't work for me either)

Please sign in to comment.