Sha256: 2a83fddf59e9eb50c4155676c0e5b0138e99a855382dbbcb3144549a634070e4

Contents?: true

Size: 937 Bytes

Versions: 11

Compression:

Stored size: 937 Bytes

Contents

require 'aws-sdk'
require 'mustache'

module Alephant
  class Renderer
    attr_reader :template_file

    def initialize(template_file, base_path, model)
      @logger        = ::Alephant.logger
      @template_file = template_file
      @base_path     = base_path
      @model         = model
      @logger.info("Renderer.initialize: end with @base_path set to #{@base_path}")
    end

    def render
      @logger.info("Renderer.render: rendered template #{template_file}")

      Mustache.render(template, @model)
    end

    def template
      template_location = File.join(@base_path, 'templates', "#{template_file}.mustache")

      begin
        @logger.info("Renderer.template: #{template_location}")
        File.open(template_location).read
      rescue Exception => e
        @logger.error("Renderer.template: view template #{template_file} not found")
        raise Errors::ViewTemplateNotFound
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alephant-0.0.9.9.1-java lib/alephant/models/renderer.rb
alephant-0.0.9.9-java lib/alephant/models/renderer.rb
alephant-0.0.9.8-java lib/alephant/models/renderer.rb
alephant-0.0.9.7-java lib/alephant/models/renderer.rb
alephant-0.0.9.6-java lib/alephant/models/renderer.rb
alephant-0.0.9.5-java lib/alephant/models/renderer.rb
alephant-0.0.9.4-java lib/alephant/models/renderer.rb
alephant-0.0.9.3-java lib/alephant/models/renderer.rb
alephant-0.0.9.2-java lib/alephant/models/renderer.rb
alephant-0.0.9.1-java lib/alephant/models/renderer.rb
alephant-0.0.9-java lib/alephant/models/renderer.rb