Sha256: 68ea73775a548d6a01810227e298790060574a8636ebf6821cf5dcabae62a657
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Locomotive module Builder module Liquid module Tags class Snippet < ::Liquid::Include def render(context) name = @template_name.gsub(/[\"\']/, '') source = context.registers[:mounting_point].snippets[name].try(:source) Locomotive::Builder::Logger.info " Rendered snippet #{name}" partial = ::Liquid::Template.parse(source) variable = context[@variable_name || @template_name[1..-2]] context.stack do @attributes.each do |key, value| context[key] = context[value] end output = (if variable.is_a?(Array) variable.collect do |variable| context[@template_name[1..-2]] = variable partial.render(context) end else context[@template_name[1..-2]] = variable partial.render(context) end) output end end end ::Liquid::Template.register_tag('include', Snippet) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_builder-1.0.0.alpha8 | lib/locomotive/builder/liquid/tags/snippet.rb |
locomotivecms_builder-1.0.0.alpha7 | lib/locomotive/builder/liquid/tags/snippet.rb |