class Statikaj::Render

Attributes

articles[RW]
category[RW]
description[RW]
title[RW]
url[RW]

Public Class Methods

new(source, options) click to toggle source
# File lib/statikaj/render.rb, line 8
def initialize(source, options)
  @source = source
  @article = options.delete(:article) if options[:article]
  @articles = options.delete(:articles) if options[:articles]
  @type = options.fetch(:type, :html)
  if options[:page] && @type == :html
    render_page(options.delete(:page))
  end
end

Public Instance Methods

article() { |self| ... } click to toggle source
# File lib/statikaj/render.rb, line 18
def article(&blk)
  yield self
  to_html do
    @article.render(@source)
  end
end
page() { |self| ... } click to toggle source
# File lib/statikaj/render.rb, line 25
def page(&blk)
  yield self
  send("to_#{@type}"){ @page }
end

Private Instance Methods

render_page(page_name) click to toggle source
# File lib/statikaj/render.rb, line 41
def render_page(page_name)
  page = File.read(@source.join("templates/pages/#{page_name}.rhtml"))
  @page = ERB.new(page).result(binding)
end
to_atom() click to toggle source
# File lib/statikaj/render.rb, line 36
def to_atom
  xml = Builder::XmlMarkup.new(:indent => 2)
  instance_eval  File.read(@source.join("templates/index.builder"))
end
to_html(&blk) click to toggle source
# File lib/statikaj/render.rb, line 31
def to_html(&blk)
  layout = File.read(@source.join('templates/layout.rhtml'))
  ERB.new(layout).result(binding)
end