Sha256: 29697b106f2c3a02656e548eb2cf8f6f97b887f1aa79d83db32a923a40494e32

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'arigato/version'

module Arigato
  class View

    TITLE = 'Special Thanks'

    attr_accessor :theme, :specs, :layout, :title

    def initialize(theme, gemfile = './Gemfile', layout = true) 
      @theme = theme
      @specs = Arigato.specs(gemfile)
      @layout = layout
      @title = TITLE
    end
    
    def render 
      @layout ? render_with_layout : render_without_layout
    end

    def render_without_layout
      content
    end

    def render_with_layout
      layout
    end

    def content
      erb(content_file).result(binding)
    end

    def layout
      erb(layout_file).result(binding)
    end

    def erb(path)
      erb = ERB.new(File.read(path), nil, '-')
      erb.filename = path
      erb 
    end

    def theme_dir
      Pathname.new(File.join(Arigato.themes_dir, theme))
    end

    def content_file
      file('content')
    end

    def layout_file
      file('layout')
    end

    def link_to(label, href, target = '_blank')
      if href
        %!<a href="#{href}" target="#{target}">#{label}</a>!
      else
        label
      end
    end

    def content_for(title = nil)
    end

    def self.author(spec)
      spec.author ? "by #{spec.author}" : ''
    end

  private

    def file(name)
      File.join(theme_dir, "#{name}.html.erb")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arigato-0.1.2 lib/arigato/view.rb