Sha256: 9846af9feb42a1863391b77a6b30b44c603f26134fc1da7f03cb5c8ec9388671
Contents?: true
Size: 927 Bytes
Versions: 4
Compression:
Stored size: 927 Bytes
Contents
# ~*~ encoding: utf-8 ~*~ module Spirit 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}. # @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 Spirit::VIEWS, self.class::TEMPLATE @view = Haml::Engine.new(File.read file, escape_html: true, format: :html5) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems