Sha256: a788f459e9eeb00c5397392e04971727697860e9b518f897abbfac5e7fb8409a

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

require 'tilt'
class Rack::App::FrontEnd::Template

  require 'rack/app/front_end/template/default_layout'

  def render(*args, &block)
    return render_result(*args, &block)
  end

  protected

  def initialize(file_path, options={})
    @file_path = file_path
    @options = options
  end

  def render_result(*args, &block)
    return Rack::App::File::Streamer.new(@file_path) unless it_is_a_template?

    layout.render { Tilt.new(@file_path).render(*args, &block) }
  end

  def it_is_a_template?
    not Tilt.templates_for(@file_path).empty?
  end

  def layout
    @options[:layout] ? Tilt.new(@options[:layout]) : DefaultLayout
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-app-front_end-0.6.0 lib/rack/app/front_end/template.rb