Sha256: c663d98f23dcffe2771926eb31b61776807cd7e1df258ffa6fe81b181a18ab35

Contents?: true

Size: 963 Bytes

Versions: 6

Compression:

Stored size: 963 Bytes

Contents

require 'alephant/logger'
require 'mustache'

module Alephant
  module Renderer
    class Mustache
      include ::Alephant::Logger

      attr_reader :template_file

      def initialize(template_file, base_path, model)
        @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")
        end
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alephant-renderer-0.0.5 lib/alephant/renderer/engines/mustache.rb
alephant-renderer-0.0.4.1 lib/alephant/renderer/engines/mustache.rb
alephant-renderer-0.0.4 lib/alephant/renderer/engines/mustache.rb
alephant-renderer-0.0.3 lib/alephant/renderer/engines/mustache.rb
alephant-renderer-0.0.2 lib/alephant/renderer/engines/mustache.rb
alephant-renderer-0.0.1 lib/alephant/renderer/engines/mustache.rb