Sha256: 688b7189f1eda5a90b2ac385345c69da595d4725ce04b1c0808fe07f1a566e6e

Contents?: true

Size: 449 Bytes

Versions: 11

Compression:

Stored size: 449 Bytes

Contents

require "ostruct"
require "erb"

module Picasa
  class Template
    attr_reader :name, :params

    def initialize(name, params)
      @name   = name
      @params = params
    end

    def file
      @file ||= IO.read(::File.expand_path("../templates/#{name}.xml.erb", __FILE__))
    end

    def struct
      @struct ||= OpenStruct.new(params)
    end

    def render
      ERB.new(file).result(struct.instance_eval { binding })
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
picasa-0.6.5 lib/picasa/template.rb
picasa-0.6.4 lib/picasa/template.rb
picasa-0.6.3 lib/picasa/template.rb
picasa-0.6.2 lib/picasa/template.rb
picasa-0.6.1 lib/picasa/template.rb
picasa-0.6.0 lib/picasa/template.rb
picasa-0.5.4 lib/picasa/template.rb
picasa-0.5.3 lib/picasa/template.rb
picasa-0.5.2 lib/picasa/template.rb
picasa-0.5.1 lib/picasa/template.rb
picasa-0.5.0 lib/picasa/template.rb