Sha256: 1ce6578e8620cb54e5d64f94f97251917760789eb7d8b4833878133789261267
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
class Guinness::View def initialize(template) @template = template end def partial(path, locals = {}) filepath = File.join File.dirname(@template), path.to_s # insert a '_' before the filename before we search _partial = Dir["#{filepath.sub(/\/(?!.*\/)/, '/_')}*"].first if _partial Tilt.new(_partial).render(self, locals) else raise "#{Guinness::EMOJI} Guinness : Unable to locate partial at: '#{filepath}'" end end # return a view body or nil if adequate template cannot be found def render template_body = Tilt.new(@template).render(self) if @layout layout = Dir[File.join(File.dirname(@template), @layout) + '*'].first raise "#{Guinness::EMOJI} Guinness : Unable to locate layout at: '#{@layout}'" unless layout @body = Tilt.new(layout).render(self) { template_body } end @body || template_body end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guinness-0.0.2 | lib/guinness/view.rb |