Class: Utopia::Content::Node::Context
- Inherits:
-
Struct
- Object
- Struct
- Utopia::Content::Node::Context
- Defined in:
- lib/utopia/content/node.rb
Overview
This is a special context in which a limited set of well defined methods are exposed in the content view.
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#state ⇒ Object
(also: #current)
Returns the value of attribute state.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Fetch an attribute from the current state or document defaults.
-
#attributes ⇒ Object
Return attributes for the current rendering state.
-
#content ⇒ Object
Return the captured content of the current node.
-
#controller ⇒ Object
Return the controller associated with the document.
-
#first ⇒ Object
Return the first rendering state in the document.
-
#links(*arguments, **options, &block) ⇒ Object
Return or enumerate links relative to the current node.
-
#localization ⇒ Object
Return the document's localization preferences.
-
#parent ⇒ Object
Return the enclosing rendering state.
-
#partial(*arguments, &block) ⇒ Object
(also: #deferred_tag)
Render or defer a partial content block.
-
#request ⇒ Object
Return the application request being rendered.
-
#response ⇒ Object
Return the document response being rendered.
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document
148 149 150 |
# File 'lib/utopia/content/node.rb', line 148 def document @document end |
#state ⇒ Object Also known as: current
Returns the value of attribute state
148 149 150 |
# File 'lib/utopia/content/node.rb', line 148 def state @state end |
Instance Method Details
#[](key) ⇒ Object
Fetch an attribute from the current state or document defaults.
198 199 200 |
# File 'lib/utopia/content/node.rb', line 198 def [] key state.attributes.fetch(key){document.attributes[key]} end |
#attributes ⇒ Object
Return attributes for the current rendering state.
191 192 193 |
# File 'lib/utopia/content/node.rb', line 191 def attributes state.attributes end |
#content ⇒ Object
Return the captured content of the current node.
206 207 208 |
# File 'lib/utopia/content/node.rb', line 206 def content document.content end |
#controller ⇒ Object
Return the controller associated with the document.
167 168 169 |
# File 'lib/utopia/content/node.rb', line 167 def controller document.controller end |
#first ⇒ Object
Return the first rendering state in the document.
218 219 220 |
# File 'lib/utopia/content/node.rb', line 218 def first document.first end |
#links(*arguments, **options, &block) ⇒ Object
Return or enumerate links relative to the current node.
227 228 229 |
# File 'lib/utopia/content/node.rb', line 227 def links(*arguments, **, &block) state.node.links(*arguments, **, &block) end |
#localization ⇒ Object
Return the document's localization preferences.
173 174 175 |
# File 'lib/utopia/content/node.rb', line 173 def localization document.localization end |
#parent ⇒ Object
Return the enclosing rendering state.
212 213 214 |
# File 'lib/utopia/content/node.rb', line 212 def parent document.parent end |
#partial(*arguments, &block) ⇒ Object Also known as: deferred_tag
Render or defer a partial content block.
153 154 155 156 157 158 159 160 161 |
# File 'lib/utopia/content/node.rb', line 153 def partial(*arguments, &block) if block_given? state.defer(&block) else state.defer do |document| document.tag(*arguments) end end end |
#request ⇒ Object
Return the application request being rendered.
179 180 181 |
# File 'lib/utopia/content/node.rb', line 179 def request document.request end |
#response ⇒ Object
Return the document response being rendered.
185 186 187 |
# File 'lib/utopia/content/node.rb', line 185 def response document end |