UtopiaSourceUtopiaContentNodeContext

class Context

This is a special context in which a limited set of well defined methods are exposed in the content view.

Definitions

def partial(*arguments, &block)

Render or defer a partial content block.

Signature

parameter arguments Array

The arguments.

yields {|document| ...}

Deferred content, when a block is given.

returns String

The deferred-content marker.

Implementation

def partial(*arguments, &block)
	if block_given?
		state.defer(&block)
	else
		state.defer do |document|
			document.tag(*arguments)
		end
	end
end

def controller

Return the controller associated with the document.

Signature

returns Controller::Variables | Nil

The current controller variables.

Implementation

def controller
	document.controller
end

def localization

Return the document's localization wrapper.

Signature

returns Localization::Wrapper

The localization wrapper.

Implementation

def localization
	document.localization
end

def request

Return the protocol request being rendered.

Signature

returns Rack::Request

The request.

Implementation

def request
	document.request
end

def response

Return the document response being rendered.

Signature

returns Document

The document response.

Implementation

def response
	document
end

def attributes

Return attributes for the current rendering state.

Signature

returns Hash

The current attributes.

Implementation

def attributes
	state.attributes
end

def [](key)

Fetch an attribute from the current state or document defaults.

Signature

parameter key String | Symbol

The lookup key.

returns Object | Nil

The state attribute, falling back to the document attribute.

Implementation

def [] key
	state.attributes.fetch(key){document.attributes[key]}
end

def content

Return the captured content of the current node.

Signature

returns String

The captured content.

Implementation

def content
	document.content
end

def parent

Return the enclosing rendering state.

Signature

returns Builder | Nil

The parent rendering state.

Implementation

def parent
	document.parent
end

def first

Return the first rendering state in the document.

Signature

returns Builder | Nil

The first rendering state.

Implementation

def first
	document.first
end