Class: Locomotive::Steam::Liquid::Tags::InheritedBlock
- Inherits:
-
Liquid::InheritedBlock
- Object
- Liquid::InheritedBlock
- Locomotive::Steam::Liquid::Tags::InheritedBlock
- Defined in:
- lib/locomotive/steam/liquid/tags/inherited_block.rb
Overview
Blocks are used with the Extends tag to define the content of blocks. Nested blocks are allowed.
{% extends home %}
{% block content }Hello world{% endblock %}
Options used to generate the UI/UX of the editable element inputs
- short_name (Boolean): use just the name and skip the name of the nested blocks.
- priority (Integer): allow blocks to be displayed before others
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ InheritedBlock
constructor
A new instance of InheritedBlock.
- #parse(tokens) ⇒ Object
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, options) ⇒ InheritedBlock
Returns a new instance of InheritedBlock.
18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/steam/liquid/tags/inherited_block.rb', line 18 def initialize(tag_name, markup, ) super @attributes = { short_name: false, priority: 0, anchor: true } markup.scan(::Liquid::TagAttributes) do |key, value| @attributes[key.to_sym] = ::Liquid::Expression.parse(value) end end |
Instance Method Details
#parse(tokens) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/locomotive/steam/liquid/tags/inherited_block.rb', line 27 def parse(tokens) super.tap do ActiveSupport::Notifications.instrument('steam.parse.inherited_block', { page: [:page], name: @name, found_super: self.contains_super?(nodelist) }.merge(@attributes)) end end |
#render(context) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/locomotive/steam/liquid/tags/inherited_block.rb', line 37 def render(context) (if live_editing?(context) && (@attributes[:anchor] || @attributes[:anchor].nil?) %{<span class="locomotive-block-anchor" data-element-id="#{@name}" style="visibility: hidden"></span>} else '' end) + super end |