Sha256: d05bdca6dfefafa96831e7437b52aa4b0d2ce4629851fe2fa6d9342e65462c54
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
Contents
module Locomotive module Liquid module Tags class WithScope < ::Liquid::Block def initialize(tag_name, markup, tokens, context) @attributes = {} markup.scan(::Liquid::TagAttributes) do |key, value| @attributes[key] = value end super end def render(context) context.stack do context['with_scope'] = decode(@attributes, context) render_all(@nodelist, context) end end private def decode(attributes, context) attributes.each_pair do |key, value| attributes[key] = (case value when /^true|false$/i then value == 'true' when /^[0-9]+$/ then value.to_i when /^["|'](.+)["|']$/ then $1.gsub(/^["|']/, '').gsub(/["|']$/, '') else context[value] end) end end end ::Liquid::Template.register_tag('with_scope', WithScope) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotive_cms-2.0.0.rc1 | lib/locomotive/liquid/tags/with_scope.rb |