use the evaluated template name as the section id

Didier Lafforgue committed May 22, 2018
commit b481b496667920876590886555ef8e4be4c13711
Showing 2 changed files with 6 additions and 5 deletions
locomotive/steam/liquid/tags/section.rb b/lib/locomotive/steam/liquid/tags/section.rb +3 -3
@@ @@ -5,7 +5,7 @@ module Locomotive
class Section < ::Liquid::Include
def parse(tokens)
- ActiveSupport::Notifications.instrument('steam.parse.section', name: @template_name)
+ ActiveSupport::Notifications.instrument('steam.parse.section', name: evaluate_section_name)
end
def render(context)
@@ @@ -21,10 +21,10 @@ module Locomotive
# 3. because it's considered as a static section, go get the content from
# the current site. If it doesn't exist, use the default attribute of
# the section
- section_content = context['site']&.sections_content&.fetch(@template_name, nil) #context["site"].sections[@template_name]
+ section_content = context['site']&.sections_content&.fetch(@template_name, nil)
if section_content.blank?
- section_content = section.definition[:default] || {}
+ section_content = section.definition[:default] || { settings: {}, blocks: [] }
end
# 4. enhance the context by setting the "section" variable
locomotive/steam/liquid/tags/snippet.rb b/lib/locomotive/steam/liquid/tags/snippet.rb +3 -2
@@ @@ -6,10 +6,11 @@ module Locomotive
class Snippet < ::Liquid::Include
def parse(tokens)
- ActiveSupport::Notifications.instrument('steam.parse.include', page: options[:page], name: @template_name)
+ name = evaluate_snippet_name
+
+ ActiveSupport::Notifications.instrument('steam.parse.include', page: options[:page], name: name)
# look for editable elements
- name = evaluate_snippet_name
if options[:snippet_finder] && snippet = options[:snippet_finder].find(name)
options[:parser]._parse(snippet, options.merge(snippet: name))
end