lib/tilt/petroglyph.rb in petroglyph-0.0.6 vs lib/tilt/petroglyph.rb in petroglyph-0.0.7
- old
+ new
@@ -1,9 +1,6 @@
# Makes Petroglyph available through Tilt.
-# Also contains a utility function that will
-# be added to Sinatra if Sinatra is defined.
-
require 'tilt'
require 'petroglyph'
module Tilt
class PetroglyphTemplate < Template
@@ -11,17 +8,19 @@
def initialize_engine
return if defined? ::Petroglyph
require_template_library 'petroglyph'
end
- def prepare; end
+ def prepare
+ @engine = Petroglyph::Engine.new(data)
+ end
def precompiled_template(locals)
data.to_str
end
def evaluate(scope = Object.new, locals = {}, &block)
- Petroglyph::Engine.new(data).render(scope, locals, file, &block)
+ @engine.render(scope, locals, file, &block)
end
end
register PetroglyphTemplate, 'pg'
end