Class: Utopia::Content::Node::Context

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#documentObject

Returns the value of attribute document

Returns:

  • (Object)

    the current value of document



146
147
148
# File 'lib/utopia/content/node.rb', line 146

def document
  @document
end

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • (Object)

    the current value of 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

#attributesObject

Return attributes for the current rendering state.



189
190
191
# File 'lib/utopia/content/node.rb', line 189

def attributes
	state.attributes
end

#contentObject

Return the captured content of the current node.



204
205
206
# File 'lib/utopia/content/node.rb', line 204

def content
	document.content
end

#controllerObject

Return the controller associated with the document.



165
166
167
# File 'lib/utopia/content/node.rb', line 165

def controller
	document.controller
end

#firstObject

Return the first rendering state in the document.



216
217
218
# File 'lib/utopia/content/node.rb', line 216

def first
	document.first
end

Return or enumerate links relative to the current node.



225
226
227
# File 'lib/utopia/content/node.rb', line 225

def links(*arguments, **options, &block)
	state.node.links(*arguments, **options, &block)
end

#localizationObject

Return the document's localization preferences.



171
172
173
# File 'lib/utopia/content/node.rb', line 171

def localization
	document.localization
end

#parentObject

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

#requestObject

Return the application request being rendered.



177
178
179
# File 'lib/utopia/content/node.rb', line 177

def request
	document.request
end

#responseObject

Return the document response being rendered.



183
184
185
# File 'lib/utopia/content/node.rb', line 183

def response
	document
end