class SimplePageLayout::Helper::PageLayout

Attributes

html_lang[RW]
site_name[RW]
view[RW]

Public Class Methods

new(view, site_name, options = {}) click to toggle source
# File lib/simple-page-layout.rb, line 8
def initialize(view, site_name, options = {})
  @view = view

  @site_name = site_name
  @html_lang = options[:html_lang]
  @body_class = options[:body_class]
end

Public Instance Methods

render(&block) click to toggle source
# File lib/simple-page-layout.rb, line 16
def render(&block)
  @view.haml_tag :html, :lang => html_lang do
    render_page_layout_head
    render_page_layout_body(&block)
  end
end
render_page_layout_body() { || ... } click to toggle source
# File lib/simple-page-layout.rb, line 36
def render_page_layout_body(&block)
  javascript_ext = @view.content_for :javascript

  @view.haml_tag :body, :class => @body_class do
    yield
    @view.haml_concat @view.javascript_include_tag(:application)
    @view.haml_concat @view.javascript_ext if javascript_ext.present?
  end
end
render_page_layout_head() click to toggle source
# File lib/simple-page-layout.rb, line 23
def render_page_layout_head
  head_ext = @view.content_for :head
  css_ext  = @view.content_for :css

  @view.haml_tag :head do
    render_page_title
    @view.haml_concat @view.csrf_meta_tags
    @view.haml_concat @view.stylesheet_link_tag(:application)
    @view.haml_concat head_ext if head_ext.present?
    @view.haml_concat css_ext if css_ext.present?
  end
end
render_page_title() click to toggle source
# File lib/simple-page-layout.rb, line 46
def render_page_title
  yield_title = @view.content_for :title
  page_title = yield_title.blank? ? @site_name : "#{@site_name} | #{yield_title}" rescue 'SITE_NAME'
  
  @view.haml_tag :title, page_title
end