class FlickrOfflineGallery::TemplateRenderer

Public Class Methods

new(template) click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 6
def initialize(template)
  @template = template
end

Public Instance Methods

render() click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 27
def render
  raise "not implemented"
end
render_erb(locals) click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 23
def render_erb(locals)
  ERB.new(template_contents).result(OpenStruct.new(locals).instance_eval { binding })
end
template_contents() click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 18
def template_contents
  raise "Unknown template: #{template_path}" unless File.exist?(template_path)
  @template_content ||= File.read(template_path)
end
template_directory() click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 14
def template_directory
  File.expand_path("../../../erb/", __FILE__)
end
template_path() click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 10
def template_path
  File.expand_path("../../../erb/#{@template}.html.erb",__FILE__)
end
write() click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 31
def write
  raise "not implemented"
end
write_file(filename) click to toggle source
# File lib/flickr_offline_gallery/template_renderer.rb, line 35
def write_file(filename)
  File.open(filename, 'w') do |file|
    file.write render
  end
  verbose_puts "Wrote out #{filename}"
end