Class: Liquid2::BlockDrop
- Inherits:
-
Object
- Object
- Liquid2::BlockDrop
- Defined in:
- lib/liquid2/nodes/tags/extends.rb
Overview
A block object available within {% block %} tags.
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(token, context, name, parent) ⇒ BlockDrop
constructor
A new instance of BlockDrop.
- #key?(key) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(token, context, name, parent) ⇒ BlockDrop
Returns a new instance of BlockDrop.
243 244 245 246 247 248 |
# File 'lib/liquid2/nodes/tags/extends.rb', line 243 def initialize(token, context, name, parent) @token = token @context = context @name = name @parent = parent end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
237 238 239 |
# File 'lib/liquid2/nodes/tags/extends.rb', line 237 def token @token end |
Instance Method Details
#[](key) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/liquid2/nodes/tags/extends.rb', line 256 def [](key) return nil if key != "super" || @parent.nil? parent = @parent || raise buf = +"" namespace = { "block" => BlockDrop.new(parent.first.token, @context, parent[2].path || parent[2].name, parent.last) } @context.extend(namespace) do parent.first.block.render(@context, buf) end buf.freeze end |
#key?(key) ⇒ Boolean
252 253 254 |
# File 'lib/liquid2/nodes/tags/extends.rb', line 252 def key?(key) key == "super" && @parent end |
#to_s ⇒ Object
250 |
# File 'lib/liquid2/nodes/tags/extends.rb', line 250 def to_s = "BlockDrop(#{@name})" |