serbea 0.5.0 → 0.6.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
  SHA256:
3
- metadata.gz: ce17e2b60c2abf63a033d8d358686d4df115e87a4c149ba3c625a403863e129c
4
- data.tar.gz: a3901a5286afc92e84b2ecc29b2622e80a592f0d0d9de46a7aa58d836e150c65
3
+ metadata.gz: edd4caa76947988e564a917a9457014cfe194d53ec8b0edf1aae5479ea8b9cf4
4
+ data.tar.gz: e93987c1eb193535cf47fc7dc57b412407d5ad6a832bc8ffd5966bc7bbc5c322
5
5
  SHA512:
6
- metadata.gz: 52aadba5419583064f26be67a99805ea66af5798b3bd3a34604967c91fdee3f2e6010ba692b6f70a2de798fa5d899bb7760fd3a76975e415932e5922c7f21c6a
7
- data.tar.gz: 4bc3fcfa08bb021ceb68ae675f4f47d4fd72a2e1cdd71fe68d8b4e435493238c49f205f10ccc52e0980d160a226433af19b70d39d18bc3d73b30c9afb8be0698
6
+ metadata.gz: e59b9abc02d1f2a272bef3adf5239fb385bde5924ad4c3a2bb2f8efe6ec11caab6cf2a4b2901fc9ea59821e119b8ea7fb9dc700a4e22773b535633284da89afe
7
+ data.tar.gz: 1bddcc5a82fa3cd62ceead72600ec621e6fcad08d2e3a6c58041cca972505917c19f89b2861514599feef93f9449c0eec78b7fbb69de97135fd2aefebcc4bab8
@@ -1,6 +1,5 @@
1
1
  require "tilt"
2
2
  require "tilt/erubi"
3
- require "erubi/capture_end"
4
3
 
5
4
  require "serbea/helpers"
6
5
  require "serbea/pipeline"
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/string/output_safety"
2
+
1
3
  module Serbea
2
4
  module Helpers
3
5
  def self.included(mod)
@@ -20,7 +22,7 @@ module Serbea
20
22
  @_erbout = previous_buffer_state
21
23
  @output_buffer = previous_ob_state
22
24
 
23
- result.respond_to?(:html_safe) ? result.html_safe : result
25
+ result.html_safe
24
26
  end
25
27
 
26
28
  def pipeline(context, value)
@@ -32,11 +34,15 @@ module Serbea
32
34
  end
33
35
 
34
36
  def h(input)
35
- result = Erubi.h(input)
36
- result.respond_to?(:html_safe) ? result.html_safe : result
37
+ ERB::Util.h(input.to_s)
37
38
  end
38
39
  alias_method :escape, :h
39
40
 
41
+ def safe(input)
42
+ input.to_s.html_safe
43
+ end
44
+ alias_method :raw, :safe
45
+
40
46
  def prepend(old_string, new_string)
41
47
  "#{new_string}#{old_string}"
42
48
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/string/output_safety"
2
+
1
3
  module Serbea
2
4
  class Pipeline
3
5
  def self.exec(template, input: (no_input_passed = true; nil), include_helpers: nil)
@@ -27,11 +29,17 @@ module Serbea
27
29
  end
28
30
  def self.output_processor
29
31
  @output_processor ||= lambda do |input|
30
- # no-op
31
- input
32
+ (!input.html_safe? && self.autoescape) ? ERB::Util.h(input) : input.html_safe
32
33
  end
33
34
  end
34
35
 
36
+ def self.autoescape=(config_boolean)
37
+ @autoescape = config_boolean
38
+ end
39
+ def self.autoescape
40
+ @autoescape.nil? ? true : @autoescape
41
+ end
42
+
35
43
  def self.raise_on_missing_filters=(config_boolean)
36
44
  @raise_on_missing_filters = config_boolean
37
45
  end
@@ -85,7 +93,7 @@ module Serbea
85
93
  end
86
94
 
87
95
  def to_s
88
- self.class.output_processor.call @value.to_s
96
+ self.class.output_processor.call(@value.is_a?(String) ? @value : @value.to_s)
89
97
  end
90
98
  end
91
99
  end
@@ -16,19 +16,7 @@ module Serbea
16
16
 
17
17
  new.compile(template, source)
18
18
  end
19
-
20
- # def cache_fragment(block, name = {}, options = nil)
21
- # @view.fragment_for(block, name, options) do
22
- # eval("_hamlout.buffer", block.binding)
23
- # end
24
- # end
25
19
  end
26
20
  end
27
21
 
28
22
  ActionView::Template.register_template_handler(:serb, Serbea::Plugin)
29
-
30
- if defined?(ActionController::Base)
31
- Serbea::Pipeline.output_processor = lambda do |input|
32
- input.html_safe? ? input : ActionController::Base.helpers.strip_tags(input)
33
- end
34
- end
@@ -38,7 +38,7 @@ module Serbea
38
38
 
39
39
  def add_postamble(postamble)
40
40
  src << postamble
41
- src << "#{@bufvar}.html_safe" if postamble.respond_to?(:html_safe)
41
+ src << "#{@bufvar}.html_safe"
42
42
 
43
43
  src.gsub!("__RAW_START_PRINT__", "{{")
44
44
  src.gsub!("__RAW_END_PRINT__", "}}")
@@ -1,3 +1,3 @@
1
1
  module Serbea
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -17,5 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_runtime_dependency("erubi", "~> 1.9")
20
+ spec.add_runtime_dependency("activesupport", "~> 6.0")
20
21
  spec.add_runtime_dependency("tilt", "~> 2.0")
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serbea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: tilt
29
43
  requirement: !ruby/object:Gem::Requirement