Sha256: 62943e448d28c6c3a61ecc34bd0cfe763c128a6e20a3016f33ecfd403b10554a
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module Locomotive module Steam module Liquid module Tags class InheritedBlock < ::Liquid::InheritedBlock def parse(tokens) super.tap do ActiveSupport::Notifications.instrument("steam.parse.inherited_block", page: options[:page], name: @name, found_super: self.contains_super?(nodelist)) end end protected def contains_super?(nodes) nodes.any? do |node| if is_node_block_super?(node) true elsif is_node_with_nodelist?(node) contains_super?(node.nodelist) end end end def is_node_block_super?(node) return unless node.is_a?(::Liquid::Variable) node.raw.strip == 'block.super' end def is_node_with_nodelist?(node) if node.respond_to?(:nodelist) && !node.is_a?(Locomotive::Steam::Liquid::Tags::InheritedBlock) # some blocks does not have a body like the link_to tag _nodelist = node.nodelist rescue nil !_nodelist.nil? end end end ::Liquid::Template.register_tag('block'.freeze, InheritedBlock) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_steam-1.0.0.pre.alpha.2 | lib/locomotive/steam/liquid/tags/inherited_block.rb |
locomotivecms_steam-1.0.0.pre.alpha.1 | lib/locomotive/steam/liquid/tags/inherited_block.rb |