Sha256: 3027262d704e675c4a3d9a53f5dbd3c8f818a09c2d96232c1fdbfd377f63482a
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'aws-sdk' require 'mustache' module Alephant class Renderer DEFAULT_LOCATION = 'views' attr_reader :id def initialize(id) @id = id end def render(data) Mustache.render( template(@id), model(@id,data) ) end def base_path @base_path || DEFAULT_LOCATION end def base_path=(path) if File.directory?(path) @base_path = path else raise Errors::InvalidViewPath end end def model(id, data) model_location = File.join(base_path,'models',"#{id}.rb") begin require model_location klass = ::Alephant::Views.get_registered_class(id) rescue Exception => e raise Errors::ViewModelNotFound end klass.new(data) end def template(id) template_location = File.join(base_path,'templates',"#{id}.mustache") begin File.open(template_location).read rescue Exception => e raise Errors::ViewTemplateNotFound end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alephant-0.0.5-java | lib/alephant/models/renderer.rb |
alephant-0.0.4-java | lib/alephant/models/renderer.rb |