Class: Locomotive::Steam::Liquid::Tags::WithScope
- Inherits:
-
Solid::Block
- Object
- Solid::Block
- Locomotive::Steam::Liquid::Tags::WithScope
- Defined in:
- lib/locomotive/steam/liquid/tags/with_scope.rb
Overview
Filter a collection
Usage:
with_scope main_developer: ‘John Doe’, providers.in: [‘acme’], started_at.le: today, active: true %
{% for project in contents.projects %}
{{ project.name }}
{% endfor %}
endwith_scope %
Constant Summary collapse
- OPERATORS =
%w(all exists gt gte in lt lte ne nin size near within)
- SYMBOL_OPERATORS_REGEXP =
/(\w+\.(#{OPERATORS.join('|')})){1}\s*\:/o
- REGEX_OPTIONS =
{ 'i' => Regexp::IGNORECASE, 'm' => Regexp::MULTILINE, 'x' => Regexp::EXTENDED }
Instance Method Summary collapse
- #display(options = {}, &block) ⇒ Object
-
#initialize(name, markup, options) ⇒ WithScope
constructor
A new instance of WithScope.
Constructor Details
#initialize(name, markup, options) ⇒ WithScope
Returns a new instance of WithScope.
32 33 34 35 36 37 |
# File 'lib/locomotive/steam/liquid/tags/with_scope.rb', line 32 def initialize(name, markup, ) # convert symbol operators into valid ruby code markup.gsub!(SYMBOL_OPERATORS_REGEXP, ':"\1" =>') super(name, markup, ) end |
Instance Method Details
#display(options = {}, &block) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/locomotive/steam/liquid/tags/with_scope.rb', line 39 def display( = {}, &block) current_context.stack do current_context['with_scope'] = self.decode() current_context['with_scope_content_type'] = false # for now, no content type is assigned to this with_scope yield end end |