class Temple::Engine


engine.compile(something)
engine = MyEngine.new(:strict => “For MyParser”)
end
generator :ArrayBuffer, :buffer
# Finally the generator
filter :DynamicInliner
filter :StaticMerger
filter :MultiFlattener
# Then some general optimizations filters
use MyFilter
# Then a custom filter
use MyParser, :strict
# First run MyParser, passing the :strict option
class MyEngine < Temple::Engine
some filters and a generator).
An engine is simply a chain of compilers (that often includes a parser,

def self.chain

def self.chain
  @chain ||= []
end

def self.filter(filter, *options, &block)

Shortcut for use Temple::Filters::parser
def self.filter(filter, *options, &block)
  use(Temple::Filters.const_get(filter), *options, &block)
end

def self.generator(compiler, *options, &block)

Shortcut for use Temple::Generators::parser
def self.generator(compiler, *options, &block)
  use(Temple::Generators.const_get(compiler), *options, &block)
end

def self.use(filter, *options, &block)

def self.use(filter, *options, &block)
  default_options = Hash === options.last ? options.pop : {}
  chain << proc do |opts|
    filter.new(default_options.merge(Hash[*opts.select {|k,v| options.include?(k) }.flatten]), &block)
  end
end

def chain

def chain
  @chain ||= self.class.chain.map { |f| f.call(options) }
end

def compile(input)

def compile(input)
  chain.inject(input) {|m, e| e.compile(m) }
end