Sha256: d442df02527008f374668c1649887f0482b572d18e57b13906eaeb1cd93084f5

Contents?: true

Size: 511 Bytes

Versions: 1

Compression:

Stored size: 511 Bytes

Contents

module Onebox
  class View < Mustache
    attr_reader :view

    self.template_path = File.join(Gem::Specification.find_by_name("onebox").gem_dir, "templates")

    def initialize(name, layout = false)
      @layout = layout
      self.template_name = unless @layout then name else "_layout" end
      @view = View.new(name) if @layout
    end

    def to_html(record)
      if @layout
        render(url: record[:url], view: @view.to_html(record))
      else
        render(record)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onebox-1.1.0 lib/onebox/view.rb