Class: Locomotive::Liquid::Tags::WithScope
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Locomotive::Liquid::Tags::WithScope
- Defined in:
- lib/locomotive/liquid/tags/with_scope.rb
Overview
Filter a collection
Usage:
with_scope main_developer: ‘John Doe’, active: true %
{% for project in contents.projects %}
{{ project.name }}
{% endfor %}
endwith_scope %
Constant Summary collapse
- TagAttributes =
/(\w+|\w+\.\w+)\s*\:\s*(#{::Liquid::QuotedFragment})/
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens, context) ⇒ WithScope
constructor
A new instance of WithScope.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens, context) ⇒ WithScope
Returns a new instance of WithScope.
20 21 22 23 24 25 26 |
# File 'lib/locomotive/liquid/tags/with_scope.rb', line 20 def initialize(tag_name, markup, tokens, context) @attributes = HashWithIndifferentAccess.new markup.scan(TagAttributes) do |key, value| @attributes[key] = value end super end |
Instance Method Details
#render(context) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/locomotive/liquid/tags/with_scope.rb', line 28 def render(context) context.stack do context['with_scope'] = decode(@attributes.clone, context) render_all(@nodelist, context) end end |