From 7512dbe0938da2cc5e0dd083bc9ffea02c0fb79a Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Wed, 3 Sep 2008 10:36:14 -0700 Subject: [PATCH] Make the Sass filter in haml files pass the Sass::Plugin options when initializing the sass engine. --- lib/haml/filters.rb | 2 +- lib/sass/plugin.rb | 15 ++++++++++----- test/haml/results/filters.xhtml | 8 ++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/haml/filters.rb b/lib/haml/filters.rb index 78349bf7..985ca4cb 100644 --- a/lib/haml/filters.rb +++ b/lib/haml/filters.rb @@ -215,7 +215,7 @@ END lazy_require 'sass/engine' def render(text) - ::Sass::Engine.new(text).render + ::Sass::Engine.new(text,::Sass::Plugin.engine_options).render end end diff --git a/lib/sass/plugin.rb b/lib/sass/plugin.rb index 7c0dd984..9a0e8ed3 100644 --- a/lib/sass/plugin.rb +++ b/lib/sass/plugin.rb @@ -34,6 +34,13 @@ module Sass @@options.merge!(value) end + # Get the options ready to be passed to the Sass::Engine + def engine_options(additional_options = {}) + l_options = @@options.dup.merge(additional_options) + l_options[:load_paths] = load_paths(l_options) + l_options + end + # Checks each stylesheet in options[:css_location] # to see if it needs updating, # and updates it using the corresponding template @@ -53,9 +60,7 @@ module Sass File.delete(css) if File.exists?(css) filename = template_filename(name) - l_options = @@options.dup - l_options[:filename] = filename - l_options[:load_paths] = load_paths + l_options = engine_options(:filename => filename) engine = Engine.new(File.read(filename), l_options) result = begin engine.render @@ -78,8 +83,8 @@ module Sass private - def load_paths - (options[:load_paths] || []) + [options[:template_location]] + def load_paths(opts = options) + (opts[:load_paths] || []) + [options[:template_location]] end def exception_string(e) diff --git a/test/haml/results/filters.xhtml b/test/haml/results/filters.xhtml index c82b1540..6e192ec0 100644 --- a/test/haml/results/filters.xhtml +++ b/test/haml/results/filters.xhtml @@ -1,11 +1,7 @@ TESTING HAHAHAHA!