locomotivecms_steam 1.6.0.rc1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +79 -39
  4. data/bin/steam.rb +1 -7
  5. data/docker-compose.yml +4 -0
  6. data/lib/locomotive/steam/configuration.rb +13 -0
  7. data/lib/locomotive/steam/entities/site.rb +1 -0
  8. data/lib/locomotive/steam/liquid/tags/concerns/attributes.rb +97 -10
  9. data/lib/locomotive/steam/liquid/tags/concerns/path.rb +23 -4
  10. data/lib/locomotive/steam/liquid/tags/consume.rb +2 -2
  11. data/lib/locomotive/steam/liquid/tags/editable/base.rb +4 -4
  12. data/lib/locomotive/steam/liquid/tags/global_section.rb +1 -1
  13. data/lib/locomotive/steam/liquid/tags/inherited_block.rb +2 -3
  14. data/lib/locomotive/steam/liquid/tags/section.rb +4 -4
  15. data/lib/locomotive/steam/liquid/tags/snippet.rb +10 -0
  16. data/lib/locomotive/steam/liquid/tags/with_scope.rb +16 -24
  17. data/lib/locomotive/steam/middlewares/auth.rb +9 -5
  18. data/lib/locomotive/steam/middlewares/concerns/auth_helpers.rb +1 -1
  19. data/lib/locomotive/steam/middlewares/concerns/helpers.rb +5 -1
  20. data/lib/locomotive/steam/middlewares/concerns/rendering.rb +1 -1
  21. data/lib/locomotive/steam/middlewares/locale.rb +5 -5
  22. data/lib/locomotive/steam/middlewares/logging.rb +2 -4
  23. data/lib/locomotive/steam/middlewares/page.rb +4 -4
  24. data/lib/locomotive/steam/middlewares/path.rb +7 -1
  25. data/lib/locomotive/steam/middlewares/private_access.rb +2 -2
  26. data/lib/locomotive/steam/middlewares/templatized_page.rb +1 -1
  27. data/lib/locomotive/steam/middlewares/timezone.rb +1 -1
  28. data/lib/locomotive/steam/version.rb +1 -1
  29. data/lib/locomotive/steam.rb +7 -0
  30. data/locomotivecms_steam.gemspec +3 -1
  31. data/spec/fixtures/default/app/content_types/accounts.yml +3 -0
  32. data/spec/spec_helper.rb +1 -1
  33. data/spec/support/helpers.rb +2 -4
  34. data/spec/unit/liquid/tags/paginate_spec.rb +1 -1
  35. data/spec/unit/liquid/tags/with_scope_spec.rb +59 -0
  36. data/spec/unit/middlewares/cache_spec.rb +4 -4
  37. data/spec/unit/middlewares/path_spec.rb +70 -0
  38. metadata +45 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c52a8de8a28e60162f058703b686dcd3b4f776a51990bcc90bd1b0ff89609fd7
4
- data.tar.gz: 316c87edf83b117562e961ba666452468af720523bd948ed88cd691438b57937
3
+ metadata.gz: 6a1f4d2ebdb1c75ddf8e389fc7d5d285da6dba496aeecd8c15525321831271d1
4
+ data.tar.gz: 46c604e1570a07662bd1776f5f3f84cd3c2106c95853028c6a9e5aa046933629
5
5
  SHA512:
6
- metadata.gz: b49614cb897afa01b679aabf5c8dbb2b10c5410212a71972dedd462850d97dbfa020d1e1ddb75571881e53f2d6c99b7006d7c1bd410a0f7bd1b7dbe10632832e
7
- data.tar.gz: c7585f401423c84cc9ca593107fe991a390ca4b58969a0ac56f6630df47a13baf9da710c55a7c92e0a4f7a13bce088585e2fa33439b095dcdb2f0774ac5b15a2
6
+ metadata.gz: 402d5b879bfd1bc6feafe3b5baa934e4caf1027a2a512aa2cc1047a41735fea6590f341660862ae600689b0fae166abc79b10add10261510967f4cc2bb185035
7
+ data.tar.gz: 2091fc30d6b46c8dbb5a3cbccfbc6e629810c27605ef4c2559b05671962ed470032793b666ba019cff266b1f38dc3dbd61616efcbf83946c8b539ad2607e768e
data/Gemfile CHANGED
@@ -9,9 +9,10 @@ group :development do
9
9
  # gem 'duktape', github: 'judofyr/duktape.rb', ref: '20ef6a5'
10
10
  # gem 'duktape', github: 'did/duktape.rb', branch: 'any-fixnum'
11
11
 
12
- gem 'puma', '~> 5.3.1'
12
+ gem 'puma', '~> 5.6.4'
13
13
  gem 'haml', '~> 5.2.0'
14
14
 
15
+ gem 'rack', '~> 2.2.3.1'
15
16
  gem 'rack-mini-profiler', '~> 0.10.1'
16
17
  gem 'flamegraph'
17
18
  gem 'stackprof' # ruby 2.1+ only
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.6.0.rc1)
4
+ locomotivecms_steam (1.6.0)
5
5
  RedCloth (~> 4.3.2)
6
6
  autoprefixer-rails (~> 8.0.0)
7
7
  bcrypt (~> 3.1.11)
@@ -19,7 +19,8 @@ PATH
19
19
  moneta (~> 1.0.0)
20
20
  morphine (~> 0.1.1)
21
21
  multi_json (~> 1.15.0)
22
- nokogiri (~> 1.11.0)
22
+ nokogiri (>= 1.11, < 1.14)
23
+ parser (~> 2.7)
23
24
  pony (~> 1.12)
24
25
  rack-cache (~> 1.7.0)
25
26
  rack-rewrite (~> 1.5.1)
@@ -28,23 +29,33 @@ PATH
28
29
  sass (~> 3.4.25)
29
30
  sprockets (~> 3.7.1)
30
31
  uglifier (~> 4.1.3)
32
+ unparser (~> 0.4)
31
33
 
32
34
  GEM
33
35
  remote: https://rubygems.org/
34
36
  specs:
35
37
  RedCloth (4.3.2)
36
- activesupport (5.2.6)
38
+ abstract_type (0.0.7)
39
+ activesupport (5.2.8.1)
37
40
  concurrent-ruby (~> 1.0, >= 1.0.2)
38
41
  i18n (>= 0.7, < 2)
39
42
  minitest (~> 5.1)
40
43
  tzinfo (~> 1.1)
41
- addressable (2.8.0)
42
- public_suffix (>= 2.0.2, < 5.0)
44
+ adamantium (0.2.0)
45
+ ice_nine (~> 0.11.0)
46
+ memoizable (~> 0.4.0)
47
+ addressable (2.8.1)
48
+ public_suffix (>= 2.0.2, < 6.0)
49
+ anima (0.3.2)
50
+ abstract_type (~> 0.0.7)
51
+ adamantium (~> 0.2)
52
+ equalizer (~> 0.0.11)
53
+ ast (2.4.2)
43
54
  attr_extras (5.2.0)
44
55
  autoprefixer-rails (8.0.0)
45
56
  execjs
46
- bcrypt (3.1.16)
47
- bson (4.11.1)
57
+ bcrypt (3.1.18)
58
+ bson (4.15.0)
48
59
  chronic (0.10.2)
49
60
  chunky_png (1.4.0)
50
61
  coffee-script (2.4.1)
@@ -64,7 +75,10 @@ GEM
64
75
  sass (>= 3.3.0, < 3.5)
65
76
  compass-import-once (1.0.5)
66
77
  sass (>= 3.2, < 3.5)
67
- concurrent-ruby (1.1.7)
78
+ concord (0.1.6)
79
+ adamantium (~> 0.2.0)
80
+ equalizer (~> 0.0.9)
81
+ concurrent-ruby (1.1.10)
68
82
  coveralls (0.8.23)
69
83
  json (>= 1.8, < 3)
70
84
  simplecov (~> 0.16.1)
@@ -72,33 +86,35 @@ GEM
72
86
  thor (>= 0.19.4, < 2.0)
73
87
  tins (~> 1.6)
74
88
  crass (1.0.6)
75
- diff-lcs (1.4.4)
76
- docile (1.3.2)
89
+ diff-lcs (1.5.0)
90
+ docile (1.4.0)
77
91
  dragonfly (1.4.0)
78
92
  addressable (~> 2.3)
79
93
  multi_json (~> 1.0)
80
94
  rack (>= 1.3)
81
95
  duktape (2.0.1.1)
96
+ equalizer (0.0.11)
82
97
  execjs (2.8.1)
83
- ffi (1.15.4)
98
+ ffi (1.15.5)
84
99
  flamegraph (0.9.5)
85
- haml (5.2.0)
100
+ haml (5.2.2)
86
101
  temple (>= 0.8.0)
87
102
  tilt
88
103
  httparty (0.16.4)
89
104
  mime-types (~> 3.0)
90
105
  multi_xml (>= 0.5.2)
91
- i18n (1.8.5)
106
+ i18n (1.12.0)
92
107
  concurrent-ruby (~> 1.0)
93
108
  i18n-spec (0.6.0)
94
109
  iso
95
- iso (0.3.0)
110
+ ice_nine (0.11.2)
111
+ iso (0.4.0)
96
112
  i18n
97
- json (2.3.1)
113
+ json (2.6.2)
98
114
  json_spec (1.1.5)
99
115
  multi_json (~> 1.0)
100
116
  rspec (>= 2.0, < 4.0)
101
- kramdown (2.3.1)
117
+ kramdown (2.3.2)
102
118
  rexml
103
119
  liquid (4.0.3)
104
120
  locomotivecms_common (0.4.0)
@@ -108,34 +124,46 @@ GEM
108
124
  stringex (~> 2.8.2)
109
125
  mail (2.7.1)
110
126
  mini_mime (>= 0.1.1)
111
- memory_profiler (0.9.14)
127
+ memoizable (0.4.2)
128
+ thread_safe (~> 0.3, >= 0.3.1)
129
+ memory_profiler (1.0.0)
112
130
  mime-types (3.3.1)
113
131
  mime-types-data (~> 3.2015)
114
- mime-types-data (3.2021.0901)
132
+ mime-types-data (3.2022.0105)
115
133
  mimetype-fu (0.1.2)
116
- mini_mime (1.1.1)
117
- mini_portile2 (2.5.3)
118
- minitest (5.14.4)
134
+ mini_mime (1.1.2)
135
+ mini_portile2 (2.8.0)
136
+ minitest (5.16.3)
119
137
  moneta (1.0.0)
120
- mongo (2.13.1)
138
+ mongo (2.13.3)
121
139
  bson (>= 4.8.2, < 5.0.0)
122
140
  morphine (0.1.1)
141
+ mprelude (0.1.0)
142
+ abstract_type (~> 0.0.7)
143
+ adamantium (~> 0.2.0)
144
+ concord (~> 0.1.5)
145
+ equalizer (~> 0.0.9)
146
+ ice_nine (~> 0.11.1)
147
+ procto (~> 0.0.2)
123
148
  multi_json (1.15.0)
124
149
  multi_xml (0.6.0)
125
- nio4r (2.5.7)
126
- nokogiri (1.11.7)
127
- mini_portile2 (~> 2.5.0)
150
+ nio4r (2.5.8)
151
+ nokogiri (1.13.8)
152
+ mini_portile2 (~> 2.8.0)
128
153
  racc (~> 1.4)
129
154
  nokogumbo (2.0.5)
130
155
  nokogiri (~> 1.8, >= 1.8.4)
131
156
  origin (2.3.1)
157
+ parser (2.7.2.0)
158
+ ast (~> 2.4.1)
132
159
  pony (1.13.1)
133
160
  mail (>= 2.0)
134
- public_suffix (4.0.6)
135
- puma (5.3.2)
161
+ procto (0.0.3)
162
+ public_suffix (5.0.0)
163
+ puma (5.6.5)
136
164
  nio4r (~> 2.0)
137
- racc (1.5.2)
138
- rack (2.2.3)
165
+ racc (1.6.0)
166
+ rack (2.2.3.1)
139
167
  rack-cache (1.7.2)
140
168
  rack (>= 0.4)
141
169
  rack-mini-profiler (0.10.7)
@@ -145,8 +173,8 @@ GEM
145
173
  rack (>= 1.0, < 3)
146
174
  rack_csrf (2.6.0)
147
175
  rack (>= 1.1.0)
148
- rake (13.0.1)
149
- rb-fsevent (0.11.0)
176
+ rake (13.0.6)
177
+ rb-fsevent (0.11.2)
150
178
  rb-inotify (0.10.1)
151
179
  ffi (~> 1.0)
152
180
  rexml (3.2.5)
@@ -176,25 +204,36 @@ GEM
176
204
  sprockets (3.7.2)
177
205
  concurrent-ruby (~> 1.0)
178
206
  rack (> 1, < 3)
179
- stackprof (0.2.16)
207
+ stackprof (0.2.21)
180
208
  stringex (2.8.5)
181
209
  sync (0.5.0)
182
210
  temple (0.8.2)
183
211
  term-ansicolor (1.7.1)
184
212
  tins (~> 1.0)
185
- thor (1.0.1)
213
+ thor (1.2.1)
186
214
  thread_safe (0.3.6)
187
- tilt (2.0.10)
188
- timecop (0.9.2)
189
- tins (1.26.0)
215
+ tilt (2.0.11)
216
+ timecop (0.9.5)
217
+ tins (1.31.1)
190
218
  sync
191
- tzinfo (1.2.9)
219
+ tzinfo (1.2.10)
192
220
  thread_safe (~> 0.1)
193
221
  uglifier (4.1.20)
194
222
  execjs (>= 0.3.0, < 3)
223
+ unparser (0.5.5)
224
+ abstract_type (~> 0.0.7)
225
+ adamantium (~> 0.2.0)
226
+ anima (~> 0.3.1)
227
+ concord (~> 0.1.5)
228
+ diff-lcs (~> 1.3)
229
+ equalizer (~> 0.0.9)
230
+ mprelude (~> 0.1.0)
231
+ parser (>= 2.6.5)
232
+ procto (~> 0.0.2)
195
233
 
196
234
  PLATFORMS
197
235
  ruby
236
+ x86_64-darwin-20
198
237
 
199
238
  DEPENDENCIES
200
239
  coveralls (~> 0.8.1)
@@ -206,7 +245,8 @@ DEPENDENCIES
206
245
  memory_profiler
207
246
  mongo (~> 2.13.1)
208
247
  origin (~> 2.3.1)
209
- puma (~> 5.3.1)
248
+ puma (~> 5.6.4)
249
+ rack (~> 2.2.3.1)
210
250
  rack-mini-profiler (~> 0.10.1)
211
251
  rack-test (~> 0.8.2)
212
252
  rake (~> 13.0.1)
@@ -215,4 +255,4 @@ DEPENDENCIES
215
255
  timecop (~> 0.9.1)
216
256
 
217
257
  BUNDLED WITH
218
- 2.1.4
258
+ 2.3.7
data/bin/steam.rb CHANGED
@@ -68,8 +68,6 @@ end.parse!
68
68
  require_relative '../lib/locomotive/steam'
69
69
  require_relative '../lib/locomotive/steam/server'
70
70
 
71
- puts options.inspect
72
-
73
71
  Locomotive::Steam.configure do |config|
74
72
  config.mode = :test
75
73
  config.adapter = options[:adapter]
@@ -77,11 +75,7 @@ Locomotive::Steam.configure do |config|
77
75
  config.asset_path = options[:asset_path]
78
76
  config.asset_host = options[:asset_host]
79
77
  config.minify_assets = false
80
- end
81
-
82
- Locomotive::Common.reset
83
- Locomotive::Common.configure do |config|
84
- config.notifier = Locomotive::Common::Logger.setup(options[:log_file])
78
+ config.log_file = options[:log_file]
85
79
  end
86
80
 
87
81
  app = Locomotive::Steam.to_app
data/docker-compose.yml CHANGED
@@ -12,4 +12,8 @@ services:
12
12
  - ./bundle:/usr/local/bundle
13
13
  depends_on:
14
14
  - db
15
+ labels:
16
+ docky.main.service: True
17
+ docky.user: ubuntu
18
+
15
19
  version: '3'
@@ -102,6 +102,19 @@ module Locomotive
102
102
  attr_accessor :render_404_if_no_site
103
103
  def render_404_if_no_site; @render_404_if_no_site.nil? ? true : @render_404_if_no_site; end
104
104
 
105
+ # Log file
106
+ #
107
+ # default: nil (ENV['LOCOMOTIVE_STEAM_LOG'] || STDOUT)
108
+ #
109
+ attr_accessor :log_file
110
+
111
+ # Log level
112
+ #
113
+ # default: ::Logger::DEBUG
114
+ #
115
+ attr_accessor :log_level
116
+ def log_level; @log_level || ::Logger::DEBUG; end
117
+
105
118
  # Lambda called once a Services instance has been built.
106
119
  # It is used when we want to change one of the services
107
120
  #
@@ -25,6 +25,7 @@ module Locomotive::Steam
25
25
  sections: nil,
26
26
  sections_content: nil,
27
27
  asset_host: nil,
28
+ allow_dots_in_slugs: false,
28
29
  routes: []
29
30
  }.merge(attributes))
30
31
  end
@@ -1,3 +1,6 @@
1
+ require 'parser/current'
2
+ require 'unparser'
3
+
1
4
  module Locomotive
2
5
  module Steam
3
6
  module Liquid
@@ -10,28 +13,52 @@ module Locomotive
10
13
 
11
14
  module Attributes
12
15
 
16
+ SyntaxWithoutComa = /^ *([a-zA-Z0-9_.]*:.*)$/
17
+ SyntaxWithComa = /^[a-zA-Z0-9 _"']*, *(.*)$/
18
+
13
19
  attr_reader :attributes, :raw_attributes
14
20
 
15
21
  private
16
22
 
17
23
  def parse_attributes(markup, default = {})
18
- @attributes = default || {}
19
- @raw_attributes = @attributes.dup
24
+ @raw_attributes = default.dup || {}
25
+ attribute_markup = ''
26
+ if markup =~ SyntaxWithoutComa
27
+ attribute_markup = $1
28
+ elsif markup =~ SyntaxWithComa
29
+ attribute_markup = $1
30
+ end
31
+ unless attribute_markup.blank?
32
+ @raw_attributes.merge!(AttributeParser.parse(attribute_markup))
33
+ end
34
+ @raw_attributes
35
+ end
20
36
 
21
- return if markup.blank?
37
+ def context_evaluate_array(vals)
38
+ vals.map { value.is_a?(::Liquid::VariableLookup) ? context.evaluate(value) : value }
39
+ end
22
40
 
23
- markup.scan(tag_attributes_regexp) do |key, value|
24
- _key = key.to_sym
41
+ def context_evaluate(vals)
42
+ vals.type
43
+ end
25
44
 
26
- @attributes[_key] = block_given? ? yield(value) : ::Liquid::Expression.parse(value)
27
- @raw_attributes[_key] = @attributes[_key]
45
+ def evaluate_attributes(context, lax: false)
46
+ @attributes = HashWithIndifferentAccess.new.tap do |hash|
47
+ raw_attributes.each do |key, value|
48
+ hash[evaluate_value(context, key, lax: lax)] = evaluate_value(context, value, lax: lax)
49
+ end
28
50
  end
29
51
  end
30
52
 
31
- def evaluate_attributes(context, lax: false)
32
- @attributes = @raw_attributes.transform_values do |value|
53
+ def evaluate_value(context, value, lax: false)
54
+ case value
55
+ when ::Liquid::VariableLookup
33
56
  _value = context.evaluate(value)
34
57
  lax && _value.nil? ? value&.name : _value
58
+ when Array then value.map { |_value| evaluate_value(context, _value) }
59
+ when Hash then value.transform_values { |_value| evaluate_value(context, _value) }
60
+ else
61
+ value
35
62
  end
36
63
  end
37
64
 
@@ -39,8 +66,68 @@ module Locomotive
39
66
  ::Liquid::TagAttributes
40
67
  end
41
68
 
42
- end
69
+ class AttributeParser
70
+ class << self
71
+ def parse(markup)
72
+ handle_hash(Parser::CurrentRuby.parse("{#{markup}}"), )
73
+ end
74
+
75
+ def handle(node)
76
+ handler = "handle_#{node.type}"
77
+ unless respond_to?(handler)
78
+ raise ::Liquid::SyntaxError.new(
79
+ "Fail to parse attributes. Unknown expression type: #{node.type.inspect}")
80
+ end
81
+ public_send handler, node
82
+ end
83
+
84
+ def handle_hash(node)
85
+ res = {}
86
+ node.children.each do | n |
87
+ res[handle(n.children[0])] = handle(n.children[1])
88
+ end
89
+ res
90
+ end
43
91
 
92
+ def handle_sym(node)
93
+ node.children[0]
94
+ end
95
+
96
+ def handle_int(node)
97
+ node.children[0]
98
+ end
99
+
100
+ def handle_str(node)
101
+ node.children[0]
102
+ end
103
+
104
+ def handle_regexp(node)
105
+ Unparser.unparse(node)
106
+ end
107
+
108
+ def handle_send(node)
109
+ ::Liquid::Expression.parse(Unparser.unparse(node))
110
+ end
111
+
112
+ def handle_true(node)
113
+ true
114
+ end
115
+
116
+ def handle_false(node)
117
+ false
118
+ end
119
+
120
+ def handle_float(node)
121
+ node.children[0]
122
+ end
123
+
124
+ def handle_array(node)
125
+ node.children.map{|n| handle(n)}
126
+ end
127
+ end
128
+ end
129
+
130
+ end
44
131
  end
45
132
  end
46
133
  end
@@ -7,7 +7,7 @@ module Locomotive
7
7
 
8
8
  Syntax = /(#{::Liquid::QuotedFragment}+)(\s*,.+)?/o
9
9
 
10
- attr_reader :handle
10
+ attr_reader :handle, :compatible_attributes
11
11
 
12
12
  def initialize(tag_name, markup, options)
13
13
  super
@@ -15,6 +15,13 @@ module Locomotive
15
15
  if markup =~ Syntax
16
16
  @handle, _attributes = $1, $2
17
17
 
18
+ # this is a hack for sites which don't follow the new syntax.
19
+ # We need this hack because the value pass by with can contain "-"
20
+ # for example : "link_to another_song, with: a-song-template"
21
+ # This will be evaluated as multiple variable by the ruby AST parser
22
+ # So we need to convert it to "link_to another_song, with: 'a-song-template'"
23
+ parse_compatible_attributes(_attributes)
24
+
18
25
  parse_attributes(_attributes)
19
26
  else
20
27
  self.wrong_syntax!
@@ -22,7 +29,7 @@ module Locomotive
22
29
  end
23
30
 
24
31
  def render_path(context, &block)
25
- evaluate_attributes(context, lax: true)
32
+ evaluate_attributes(context)
26
33
 
27
34
  set_vars_from_context(context)
28
35
 
@@ -46,6 +53,18 @@ module Locomotive
46
53
 
47
54
  protected
48
55
 
56
+ def parse_compatible_attributes(_attributes)
57
+ if _attributes
58
+ _compatible_attributes = _attributes.dup
59
+ %w(with locale).each do |name|
60
+ _compatible_attributes.gsub!(/#{name}: ([\w-]+)/, name + ': "\1"')
61
+ end
62
+ @compatible_attributes = parse_attributes(_compatible_attributes)
63
+ else
64
+ @compatible_attributes = {}
65
+ end
66
+ end
67
+
49
68
  def services
50
69
  @context.registers[:services]
51
70
  end
@@ -86,11 +105,11 @@ module Locomotive
86
105
  end
87
106
 
88
107
  def locale
89
- attributes[:locale] || @locale
108
+ attributes[:locale] || compatible_attributes[:locale] || @locale
90
109
  end
91
110
 
92
111
  def template_slug
93
- attributes[:with]
112
+ attributes[:with] || compatible_attributes[:with]
94
113
  end
95
114
 
96
115
  def set_vars_from_context(context)
@@ -25,9 +25,9 @@ module Locomotive
25
25
  super
26
26
 
27
27
  if markup =~ Syntax
28
- @variable_name, @url_expr, attributes = $1.to_s, ::Liquid::Expression.parse($2), $3
28
+ @variable_name, @url_expr, _attributes = $1.to_s, ::Liquid::Expression.parse($2), $3
29
29
 
30
- parse_attributes(attributes)
30
+ parse_attributes(_attributes)
31
31
  else
32
32
  raise ::Liquid::SyntaxError.new("Syntax Error in 'consume' - Valid syntax: consume <var> from \"<url>\" [username: value, password: value]")
33
33
  end
@@ -119,11 +119,11 @@ module Locomotive
119
119
  block: self.current_inherited_block_name,
120
120
  label: label,
121
121
  slug: slug,
122
- hint: attributes[:hint],
123
- priority: attributes[:priority] || 0,
124
- fixed: [true, 'true'].include?(attributes[:fixed]),
122
+ hint: raw_attributes[:hint],
123
+ priority: raw_attributes[:priority] || 0,
124
+ fixed: [true, 'true'].include?(raw_attributes[:fixed]),
125
125
  disabled: false,
126
- inline_editing: [true, 'true'].include?(attributes[:inline_editing]),
126
+ inline_editing: [true, 'true'].include?(raw_attributes[:inline_editing]),
127
127
  from_parent: false,
128
128
  type: @tag_name.to_sym
129
129
  }
@@ -9,7 +9,7 @@ module Locomotive
9
9
  source: :site,
10
10
  id: "site-#{section_type}",
11
11
  key: section_type,
12
- placement: attributes[:placement]&.to_sym
12
+ placement: raw_attributes[:placement]&.to_sym
13
13
  )
14
14
  end
15
15
 
@@ -72,7 +72,7 @@ module Locomotive
72
72
  page: parse_context[:page],
73
73
  name: name,
74
74
  found_super: self.contains_super?(nodelist)
75
- }.merge(attributes))
75
+ }.merge(raw_attributes))
76
76
  end
77
77
  end
78
78
 
@@ -85,8 +85,7 @@ module Locomotive
85
85
 
86
86
  # the block drop is in charge of rendering "{{ block.super }}"
87
87
  context['block'] = Drops::InheritedBlock.new(block)
88
-
89
- anchor_html = if live_editing?(context) && (attributes[:anchor] || attributes[:anchor].nil?)
88
+ anchor_html = if live_editing?(context) && (raw_attributes[:anchor] || raw_attributes[:anchor].nil?)
90
89
  %{<span class="locomotive-block-anchor" data-element-id="#{name}" style="visibility: hidden"></span>}
91
90
  else
92
91
  ''
@@ -24,10 +24,10 @@ module Locomotive
24
24
 
25
25
  def parse(tokens)
26
26
  notify_on_parsing(section_type,
27
- id: "page-#{attributes[:id] || section_type}",
28
- key: (attributes[:id] || section_type).to_s,
29
- label: attributes[:label],
30
- placement: attributes[:placement]&.to_sym
27
+ id: "page-#{raw_attributes[:id] || section_type}",
28
+ key: (raw_attributes[:id] || section_type).to_s,
29
+ label: raw_attributes[:label],
30
+ placement: raw_attributes[:placement]&.to_sym
31
31
  )
32
32
  end
33
33
 
@@ -11,6 +11,16 @@ module Locomotive
11
11
  # NOTE: it doesn't support dynamically choosen template
12
12
  template_name = template_name_expr.respond_to?(:name) ? template_name_expr.name : template_name_expr
13
13
 
14
+ # make sure we keep track of the parsed snippets
15
+ parse_context[:parsed_snippets] ||= []
16
+
17
+ # already parsed? (it happens when doing recursivity with snippets)
18
+ if parse_context[:parsed_snippets].include?(template_name)
19
+ return
20
+ else
21
+ parse_context[:parsed_snippets] << template_name
22
+ end
23
+
14
24
  ActiveSupport::Notifications.instrument('steam.parse.include', page: parse_context[:page], name: template_name)
15
25
 
16
26
  if parse_context[:snippet_finder] && snippet = parse_context[:snippet_finder].find(template_name)