Sha256: a223c9aeb46886ea6143178e20545ac33f3975b43de8509000aaece120a228b1
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# ~*~ encoding: utf-8 ~*~ module Aladdin module Render # Base class for all templates. Child classes should provide a +TEMPLATE+ # string constant that contains the path to the relevant HAML file. class Template # Renders the given problem using {#view}. # @todo TODO should probably show some error message in the preview, # so that the author doesn't have to read the logs. # @param [Hash] locals local variables to pass to the template def render(locals={}) view.render Object.new, locals end private # Retrieves the +view+ singleton. If it is nil, initializes it from # +self.class.TEMPLATE+. Note that this is reloaded with every refresh so # I can edit the templates without refreshing. # @return [Haml::Engine] haml engine def view return @view unless @view.nil? file = File.join Aladdin::VIEWS[:haml], self.class::TEMPLATE @view = Haml::Engine.new(File.read file) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aladdin-0.0.7 | lib/aladdin/render/templates/template.rb |
aladdin-0.0.6 | lib/aladdin/render/templates/template.rb |