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
146 147 148 |
# File 'lib/utopia/content/node.rb', line 146 def document @document end |
#state ⇒ Object Also known as: current
Returns the value of attribute state
146 147 148 |
# File 'lib/utopia/content/node.rb', line 146 def state @state end |
Instance Method Details
#[](key) ⇒ Object
Fetch an attribute from the current state or document defaults.
196 197 198 |
# File 'lib/utopia/content/node.rb', line 196 def [] key state.attributes.fetch(key){document.attributes[key]} end |
#attributes ⇒ Object
Return attributes for the current rendering state.
189 190 191 |
# File 'lib/utopia/content/node.rb', line 189 def attributes state.attributes end |
#content ⇒ Object
Return the captured content of the current node.
204 205 206 |
# File 'lib/utopia/content/node.rb', line 204 def content document.content end |
#controller ⇒ Object
Return the controller associated with the document.
165 166 167 |
# File 'lib/utopia/content/node.rb', line 165 def controller document.controller end |
#first ⇒ Object
Return the first rendering state in the document.
216 217 218 |
# File 'lib/utopia/content/node.rb', line 216 def first document.first end |
#links(*arguments, **options, &block) ⇒ Object
Return or enumerate links relative to the current node.
225 226 227 |
# File 'lib/utopia/content/node.rb', line 225 def links(*arguments, **, &block) state.node.links(*arguments, **, &block) end |
#localization ⇒ Object
Return the document's localization preferences.
171 172 173 |
# File 'lib/utopia/content/node.rb', line 171 def localization document.localization end |
#parent ⇒ Object
Return the enclosing rendering state.
210 211 212 |
# File 'lib/utopia/content/node.rb', line 210 def parent document.parent end |
#partial(*arguments, &block) ⇒ Object Also known as: deferred_tag
Render or defer a partial content block.
151 152 153 154 155 156 157 158 159 |
# File 'lib/utopia/content/node.rb', line 151 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.
177 178 179 |
# File 'lib/utopia/content/node.rb', line 177 def request document.request end |
#response ⇒ Object
Return the document response being rendered.
183 184 185 |
# File 'lib/utopia/content/node.rb', line 183 def response document end |