module Haml::Filters::TiltFilter
def self.extended(base)
def self.extended(base) base.options = {} # There's a bug in 1.9.2 where the same parse tree cannot be shared # across several singleton classes -- this bug is fixed in 1.9.3. # We work around this by using a string eval instead of a block eval # so that a new parse tree is created for each singleton class. base.instance_eval %Q{ include Base def render_with_options(text, compiler_options) text = template_class.new(nil, 1, options) {text}.render super(text, compiler_options) end } end
def template_class
def template_class (@template_class if defined? @template_class) or begin @template_class = Tilt["t.#{tilt_extension}"] or raise Error.new(Error.message(:cant_run_filter, tilt_extension)) rescue LoadError => e dep = e.message.split('--').last.strip raise Error.new(Error.message(:gem_install_filter_deps, tilt_extension, dep)) end end