module Haml::Filters::Base

def compile(precompiler, text)

and should test your filter when upgrading to new Haml versions.
you'll probably need to look at the source code
If you want to make use of it,
nor guaranteed to be stable.
Warning: the Haml::Precompiler interface is neither well-documented

that will be executed in the context of the active Haml template.
compile uses the Haml::Precompiler instance to compile the string to Ruby code
Rather than applying a filter to a string at compile-time,
to the Haml evaluation context.
compile should be overridden when a filter needs to have access
def compile(precompiler, text)
  resolve_lazy_requires
  filter = self
  precompiler.instance_eval do
    if contains_interpolation?(text)
      return if options[:suppress_eval]
      push_script(<<RUBY, false)
nd_preserve(#{filter.inspect}.render(#{unescape_interpolation(text)}))
      return
    end
    rendered = Haml::Helpers::find_and_preserve(filter.render(text), precompiler.options[:preserve])
    if !options[:ugly]
      push_text(rendered.rstrip.gsub("\n", "\n#{'  ' * @output_tabs}"))
    else
      push_text(rendered.rstrip)
    end
  end
end