Sha256: df9c439365c8786d610bf50ccac61223d1d771f539bcc38233bb3cd2f39b3348

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

Treetop.load File.dirname(__FILE__) + '/slippers'

module Slippers
  class Engine
    DEFAULT_STRING = ''
    def initialize(template, params={})
      @main_template = Slippers::Template.new(template)
      @template_group = params[:template_group]
    end
    attr_reader :main_template, :template_group
    
    def render(object_to_render=nil)
      parser = SlippersParser.new
      parse_tree = parser.parse(@main_template.template)
      return '' unless parse_tree
      parse_tree.eval(object_to_render, @template_group) 
    end
    
    def eql?(other)
      @main_template.eql?(other.main_template) && @template_group.eql?(other.template_group)
    end
    
    def hash
      @main_template.hash + @template_group.hash*23
    end

  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
starapor-slippers-0.0.9 lib/engine/engine.rb
slippers-0.0.10 lib/engine/engine.rb