Class: Breadcrumbs::Render::Base
- Inherits:
-
Object
- Object
- Breadcrumbs::Render::Base
- Defined in:
- lib/breadcrumbs/render/base.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#breadcrumbs ⇒ Object
readonly
Returns the value of attribute breadcrumbs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#default_options ⇒ Hash
abstract
Default options.
-
#initialize(breadcrumbs, options = {}) ⇒ Base
constructor
A new instance of Base.
-
#render ⇒ String
abstract
The rendered HTML.
-
#tag(name, *args, &block) ⇒ Object
Build a HTML tag.
Constructor Details
#initialize(breadcrumbs, options = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/breadcrumbs/render/base.rb', line 7 def initialize(, = {}) @breadcrumbs = @options = .merge() end |
Instance Attribute Details
#breadcrumbs ⇒ Object (readonly)
Returns the value of attribute breadcrumbs.
5 6 7 |
# File 'lib/breadcrumbs/render/base.rb', line 5 def @breadcrumbs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/breadcrumbs/render/base.rb', line 5 def @options end |
Instance Method Details
#default_options ⇒ Hash
This method is abstract.
Returns default options.
14 15 16 |
# File 'lib/breadcrumbs/render/base.rb', line 14 def { :class => "breadcrumbs" } end |
#render ⇒ String
This method is abstract.
Returns the rendered HTML.
20 21 22 |
# File 'lib/breadcrumbs/render/base.rb', line 20 def render "" end |
#tag(name, *args, &block) ⇒ Object
Build a HTML tag.
tag(:p, "Hello!")
tag(:p, "Hello!", :class => "hello")
tag(:p, :class => "phrase") { "Hello" }
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/breadcrumbs/render/base.rb', line 30 def tag(name, *args, &block) = args.pop if args.last.kind_of?(Hash) ||= {} content = args.first content = self.instance_eval(&block) if block_given? attrs = " " + .collect {|n, v| %[%s="%s"] % [n, v] }.join(" ") unless .empty? %[<#{name}#{attrs}>#{content}</#{name}>] end |