editmode 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c56cee03d73400139003e5a7b643e5ba0cc87827dd8373f973e4e5bbbf41e234
4
- data.tar.gz: 5cc247b0737cf3a34a7b7507895ff5b6b67d14363bd4ef328ab0630155ac8cd2
3
+ metadata.gz: 64a20fe2b3a8ccf1cd1dafc516a2484b6f4ce6701ecdd2d4f2b8a431137959bd
4
+ data.tar.gz: 683549e7c9085dda0d1ef74ff7e2b142fa746372c1da288af5e154017b69b957
5
5
  SHA512:
6
- metadata.gz: 909f2860b00987679e572d4c7c3202fe208fc7cc99ae75df7b698e5371b97f90861f65598193a0882fd924ec653978c0547d57bdc66ec2ad76651b6d1358aff1
7
- data.tar.gz: 6ccc29e44f1cd14ad281c182a78904f74a199b1b9fc22fe5cf7757753b24b3ac5eeb9a0db2098e34662b0e1448a49831e9bc99db7f78ff931485ae64cded024b
6
+ metadata.gz: 92953c97a18f6fb3b91389f4beab95ffc75f92bf91e4a603094a016c6673724c49442a46643259b0e9a9c4b48c855f9821eee7e19b7801cf2fca2b1d8c2cce4b
7
+ data.tar.gz: 3763c6e47edd0cd6c326a7cc80a0583b20d3a9db66d652b3416c643548a3356e45896846ea321b4a63f3b605e07a6f1df3dc6b8f070b63939d5b6b86fbb3c2a6
@@ -135,7 +135,7 @@ module Editmode
135
135
  end
136
136
  else
137
137
  content_tag("em-span", :class => css_class, :data => chunk_data.merge!({:chunk_editable => true}) ) do
138
- chunk_content
138
+ chunk_content.html_safe
139
139
  end
140
140
  end
141
141
  when "image"
@@ -162,7 +162,6 @@ module Editmode
162
162
  url = "#{api_root_url}/chunks/#{identifier}?project_id=#{Editmode.project_id}&#{branch_params}"
163
163
  cached_content_present = Rails.cache.exist?(cache_identifier)
164
164
  parent_identifier = identifier if field.present?
165
-
166
165
  if !cached_content_present
167
166
  response = HTTParty.get(url)
168
167
  response_received = true if response.code == 200
@@ -233,7 +232,7 @@ module Editmode
233
232
  alias_method :E, :render_chunk
234
233
 
235
234
 
236
- def variable_parse!(content, variables = {}, values = {})
235
+ def variable_parse!(content, variables = {}, values = {}, raw = false)
237
236
  tokens = content.scan(/\{{(.*?)\}}/)
238
237
  if tokens.any?
239
238
  tokens.flatten!
@@ -241,6 +240,12 @@ module Editmode
241
240
  token_value = values[token.to_sym] || variables[token] || ""
242
241
  sanitized_value = ActionController::Base.helpers.sanitize(token_value)
243
242
 
243
+ unless raw
244
+ sanitized_value = content_tag("em-var", :data => {chunk_variable: token, chunk_variable_value: sanitized_value}) do
245
+ sanitized_value
246
+ end
247
+ end
248
+
244
249
  content.gsub!("{{#{token}}}", sanitized_value)
245
250
  end
246
251
  end
@@ -23,7 +23,7 @@ module Editmode
23
23
  field_content = @content.detect {|f| f["custom_field_identifier"].downcase == field || f["custom_field_name"].downcase == field }
24
24
  if field_content.present?
25
25
  result = field_content['content']
26
- result = variable_parse!(result, variable_fallbacks, variable_values)
26
+ result = variable_parse!(result, variable_fallbacks, variable_values, true)
27
27
  else
28
28
  raise no_response_received(field)
29
29
  end
@@ -33,13 +33,15 @@ module Editmode
33
33
  else
34
34
  raise "undefined method 'field` for chunk_type: #{chunk_type} \n"
35
35
  end
36
- result || @content
36
+ result ||= @content
37
+ result.try(:html_safe)
37
38
  end
38
39
 
39
40
  def content
40
41
  raise "undefined method 'content` for chunk_type: collection_item \nDid you mean? field" if chunk_type == 'collection_item'
41
42
 
42
- variable_parse!(@content, variable_fallbacks, variable_values)
43
+ result = variable_parse!(@content, variable_fallbacks, variable_values, true)
44
+ result.try(:html_safe)
43
45
  end
44
46
 
45
47
  private
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editmode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Ennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-21 00:00:00.000000000 Z
11
+ date: 2020-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler