Module: Weft::Page::Head::ClassMethods
- Defined in:
- lib/weft/page/head.rb
Instance Method Summary collapse
-
#title(value = nil, &block) ⇒ Object
Declare the page's
. -
#title_declaration ⇒ Object
The declared title (own or nearest inherited); nil when no ancestor declares.
Instance Method Details
#title(value = nil, &block) ⇒ Object
Declare the page's
(params) → value function run
in the verb sandbox, like every other verb block.
title "Orders"
title { |params| "Order ##{params.order_id}" }
The nearest declaration in the class ancestry wins; without one anywhere, the title falls back to "Weft".
28 29 30 31 32 33 34 35 36 |
# File 'lib/weft/page/head.rb', line 28 def title(value = nil, &block) if value && block raise Weft::InvalidDefinition, "#{name}: title takes a value or a block, not both" elsif value.nil? && block.nil? raise Weft::InvalidDefinition, "#{name}: title needs a value or a block" end @title_declaration = block || value end |
#title_declaration ⇒ Object
The declared title (own or nearest inherited); nil when no ancestor declares.
39 40 41 42 43 44 45 |
# File 'lib/weft/page/head.rb', line 39 def title_declaration if instance_variable_defined?(:@title_declaration) @title_declaration elsif superclass.respond_to?(:title_declaration) superclass.title_declaration end end |