Module: Viewaide::Helpers::StructureHelper

Included in:
Viewaide::Helpers
Defined in:
lib/viewaide/helpers/structure_helper.rb

Instance Method Summary collapse

Instance Method Details

#blockquote(*args, &block) ⇒ String

Generate a blockquote

Examples:

<% blockquote do %>Quoted text<% end %>
generates
<blockquote>Quoted text</blockquote>
<% blockquote :author => "W. Shakespeare" do %>All the world's a stage<% end %>
generates
<div class="quote-cited">
  <blockquote>All the world's a stage</blockquote>
  <cite>W. Shakespeare</cite>
</div>

Parameters:

  • (*Args)

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/viewaide/helpers/structure_helper.rb', line 20

def blockquote(*args, &block)
  options = args.extract_options!
  author = options.delete(:author)
  option_quote = textilize(options.delete(:quote))

  bq =   :blockquote,
                    option_quote.blank? ? capture(&block) : option_quote

  html = if author
     :div,
                bq + (:cite, author),
                :class => "quote-cited"
  else
    bq
  end

  concat(html)
end

#body(*args) ⇒ String

Allows assignment of <body> attributes. The body (when accepting a block) should be used in your application’s layout

Examples:

<% body do %>body goes here<% end %>
generates
<body>body goes here</body>
<% body :home, "logged-in", :id => "application" do %>body goes here<% end %>
generates
<body class="home logged-in" id="application">body goes here</body>
<% body :home, "logged-in" %> # within an ERB template
<% body :id => "application" %> # within a different ERB template
<% body do %>body goes here<% end %> # within application layout
generates
<body class="home logged-in" id="application">body goes here</body>

Parameters:

  • (*Args)

Returns:

  • (String)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/viewaide/helpers/structure_helper.rb', line 59

def body(*args)
  options = args.extract_options!
  @_page_body_attributes ||= {}

  css_classes = [] << @_page_body_attributes.delete(:class) << args

  @_page_body_attributes = @_page_body_attributes.merge(options)
  @_page_body_attributes[:class] = clean_css_classes(css_classes)

  if block_given?
    block = lambda { yield }

    html = (:body, capture(&block), @_page_body_attributes)
    concat(html)
  end
end