locomotivecms_wagon 1.5.0.rc1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eb1d85c3211cccddf3105489a759908fdd12832
|
4
|
+
data.tar.gz: 62a514ee0e9d0a749feb6dc18a09e696cd1b2e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f0f662eaa63ae25c3ab9b52bd7f732e7352ca956827b4e2b5471575fe542398e823c6b6b321157163c20b2147cb913d2887bc017469d68811962730d68e9d52
|
7
|
+
data.tar.gz: 3d16d23bec319002eb7a0f185044364eb3dcd69b8bfd99612d04f9afca762f7c90fd7fb5a9e3e7730b0557dc674139963dc8cd898335d939be51836da3eb82e6
|
@@ -2,42 +2,46 @@ module Locomotive
|
|
2
2
|
module Wagon
|
3
3
|
module Liquid
|
4
4
|
module Tags
|
5
|
-
class WithScope < ::Liquid::Block
|
6
5
|
|
7
|
-
|
8
|
-
TagAttributes = /(\w+|\w+\.\w+)\s*\:\s*(#{SlashedString}|#{::Liquid::QuotedFragment})/
|
6
|
+
class WithScope < Solid::Block
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
OPERATORS = %w(all exists gt gte in lt lte ne nin size near within)
|
9
|
+
|
10
|
+
SYMBOL_OPERATORS_REGEXP = /(\w+\.(#{OPERATORS.join('|')})){1}\s*\:/
|
11
|
+
|
12
|
+
# register the tag
|
13
|
+
tag_name :with_scope
|
14
|
+
|
15
|
+
def initialize(tag_name, arguments_string, tokens, context = {})
|
16
|
+
# convert symbol operators into valid ruby code
|
17
|
+
arguments_string.gsub!(SYMBOL_OPERATORS_REGEXP, ':"\1" =>')
|
18
|
+
|
19
|
+
super(tag_name, arguments_string, tokens, context)
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
def display(options = {}, &block)
|
23
|
+
current_context.stack do
|
24
|
+
current_context['with_scope'] = self.decode(options)
|
25
|
+
yield
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
def decode(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
protected
|
30
|
+
|
31
|
+
def decode(options)
|
32
|
+
HashWithIndifferentAccess.new.tap do |hash|
|
33
|
+
options.each do |key, value|
|
34
|
+
hash[key] = (case value
|
35
|
+
# regexp inside a string
|
36
|
+
when /^\/[^\/]*\/$/ then Regexp.new(value[1..-2])
|
37
|
+
else
|
38
|
+
value
|
39
|
+
end)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
40
|
-
::Liquid::Template.register_tag('with_scope', WithScope)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
---
|
2
2
|
title: Various uses of the with_scope tag
|
3
3
|
---
|
4
|
-
{% assign
|
5
|
-
{% assign
|
6
|
-
{% assign prices
|
4
|
+
{% assign begin_date = '2012-06-01 00:00:00' %}
|
5
|
+
{% assign end_date = '2012-06-10 23:59:59' %}
|
6
|
+
{% assign prices = '5.0,5.5' | split: ',' | map: 'to_f' %}
|
7
7
|
|
8
|
-
{% with_scope date.gte:
|
8
|
+
{% with_scope date.gte: begin_date, date.lte: end_date, city: /Kansas/, state.ne: 'Illinois', tags: 'awesome', tags.nin: 'bad', price.in: prices, order_by: 'price.desc' %}
|
9
9
|
events={{ contents.events.count }}.
|
10
10
|
{% endwith_scope %}
|
11
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_wagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -845,9 +845,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
845
845
|
version: '0'
|
846
846
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
847
847
|
requirements:
|
848
|
-
- - "
|
848
|
+
- - ">="
|
849
849
|
- !ruby/object:Gem::Version
|
850
|
-
version:
|
850
|
+
version: '0'
|
851
851
|
requirements: []
|
852
852
|
rubyforge_project:
|
853
853
|
rubygems_version: 2.2.2
|