Class: Markaby::Rails::Builder

Inherits:
RailsBuilder show all
Defined in:
lib/markaby/rails/deprecated.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Builder

Builder::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Builder

#output_helpers, #tagset

Instance Method Summary collapse

Methods inherited from RailsBuilder

#form_for

Methods inherited from Builder

#capture, get, #helper=, ignore_helpers, ignored_helpers, #locals=, restore_defaults!, set, #tag!, #text, #to_s

Methods included from BuilderTags

#head, #html_tag, #xhtml_frameset, #xhtml_strict, #xhtml_transitional

Constructor Details

#initialize(*args, &block) ⇒ Builder

Returns a new instance of Builder.



70
71
72
73
74
# File 'lib/markaby/rails/deprecated.rb', line 70

def initialize(*args, &block)
  super *args, &block

  @assigns.each { |k, v| @helpers.instance_variable_set("@#{k}", v) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Markaby::Builder

Instance Method Details

#_erboutObject

Emulate ERB to satisfy helpers like form_for.



81
82
83
# File 'lib/markaby/rails/deprecated.rb', line 81

def _erbout
  @_erbout ||= FauxErbout.new(self)
end

#content_for(name, &block) ⇒ Object

Content_for will store the given block in an instance variable for later use in another template or in the layout.

The name of the instance variable is content_for_<name> to stay consistent with @content_for_layout which is used by ActionView’s layouts.

Example:

content_for("header") do
  h1 "Half Shark and Half Lion"
end

If used several times, the variable will contain all the parts concatenated.



98
99
100
101
# File 'lib/markaby/rails/deprecated.rb', line 98

def content_for(name, &block)
  @helpers.assigns["content_for_#{name}"] =
    eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)")
end

#flash(*args) ⇒ Object



76
77
78
# File 'lib/markaby/rails/deprecated.rb', line 76

def flash(*args)
  @helpers.controller.send(:flash, *args)
end