Module: Ramaze::Helper::Markaby

Defined in:
lib/ramaze/helper/markaby.rb

Overview

Allows you to use some shortcuts for markaby in your Controller.

Instance Method Summary collapse

Instance Method Details

#markaby(ivs = {}, helpers = nil, &block) ⇒ Object Also known as: mab

Use this inside your controller to directly build Markaby Refer to the Markaby-documentation and testsuite for more examples.

Examples:

mab { h1 "Apples & Oranges"}  #=> "<h1>Apples &amp; Oranges</h1>"
mab { h1 'Apples', :class => 'fruits&floots' }


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ramaze/helper/markaby.rb', line 16

def markaby(ivs = {}, helpers = nil, &block)
  builder = ::Markaby::Builder
  builder.extend(Ramaze::Helper::Methods)
  builder.send(:helper, :link)

  iv_hash = {}
  instance_variables.each do |iv|
    key, value = iv.gsub('@', '').to_sym, instance_variable_get(iv)
    iv_hash[key] = value
  end

  builder.new(iv_hash.merge(ivs), helpers, &block).to_s
end