Class: Cecil::BlockContext
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Cecil::BlockContext
- Extended by:
- Forwardable
- Defined in:
- lib/cecil/block_context.rb
Overview
The BlockContext contains methods available to you inside a Cecil block.
Methods available in the scope of a Cecil block are:
- Methods & variables from local scope
- BlockContext instance methods for emitting code (listed below)
- Helper methods in your Code subclass'
Helpers
. See Code for defining your own helper methods.
Instance Method Summary collapse
-
#`(source_string) ⇒ Object
Alias for #src.
-
#content_for(key, &) ⇒ nil
Stores content for the given key to be insert at a different location in the document.
-
#content_for!(key) ⇒ Array<Node::Detached>
Returns the content stored for the given key, and raises an exception if there is no content stored.
-
#content_for?(key) ⇒ Boolean
Returns whether there is any content stored for the given key.
-
#defer(&) ⇒ Node::Deferred
Defer execution of the the given block until the rest of the document is evaluated and insert any content in the document where this method was called.
-
#src(source_string) ⇒ Node
Inserts a node with the given source string.
Instance Method Details
#`(source_string) ⇒ Object
Alias for #src
60 |
# File 'lib/cecil/block_context.rb', line 60 def `(source_string) = @builder.src(source_string) |
#content_for(key) ⇒ nil #content_for(key) { ... } ⇒ nil
Stores content for the given key to be insert at a different location in the document.
If a block is passed, it will be executed and the result stored. If no block is passed but the key already has content, it will be retrieved. Otherwise, content rendering will be deferred until later.
128 |
# File 'lib/cecil/block_context.rb', line 128 def_delegator :@builder, :content_for |
#content_for!(key) ⇒ Array<Node::Detached>
Returns the content stored for the given key, and raises an exception if there is no content stored. Calling
#content_for! is evaluated immeditately and will raise an exception even if #content_for(key) { ... }
is
called later.
148 |
# File 'lib/cecil/block_context.rb', line 148 def_delegator :@builder, :content_for! |
#content_for?(key) ⇒ Boolean
Returns whether there is any content stored for the given key.
This method returns immediately and will return
false even if #content_for(key) { ... }
is called later.
138 |
# File 'lib/cecil/block_context.rb', line 138 def_delegator :@builder, :content_for? |
#defer(&) ⇒ Node::Deferred
Defer execution of the the given block until the rest of the document is evaluated and insert any content in the document where this method was called.
67 |
# File 'lib/cecil/block_context.rb', line 67 def_delegator :@builder, :defer |