serbea 0.3.1 → 0.3.2

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: 9dfc45d5f8581d988481bf56c492498b5bbd8b08186910c655e6fa0964fe48dc
4
- data.tar.gz: a25507d87ae9eeed0f575cdc5825212ca5d3bfadd1fbe388b7dfc219b53d721d
3
+ metadata.gz: fdeba2843c805f483e3514fbceaa63d610ac9b436762b8ff7c34ae6f7f6d8c3a
4
+ data.tar.gz: 325e190e80f4cc5cd777e824c512361a71435b482672c1da8d17bf4ffc4d639c
5
5
  SHA512:
6
- metadata.gz: 3da42d61791e24028f5ac9c68c24c6cf73d98f7568ffa87fb04cca4c8f45b77d9dddc4a68025cbbd7e9f58429ccaa95e79eecdae249b7a272d424cf32648ed36
7
- data.tar.gz: 216bdddc4a48696fabac9321e9f6d25b63e15adda17a22041f23b7963fd7a807a7840ddfb4e289349309361d8f6285801f651822b0ec86538d07980c54c3fb8b
6
+ metadata.gz: fbfa7787a1ed422c4e1e238f2f328c37586e65d1bcc11458e6650803d8d6bfc21a6204bbdd6fa5e038b15e2120d43d08ef9a327e2ff25500e7bd569078d11a0e
7
+ data.tar.gz: b8789ea01c5eb34aed8ceb0d770b94401d6a7167d0fca38d9892ca79d4be7681b30705fb96061e31a9f52aaf5babaa9af4fa57921cab665c63f414bf286408ae
@@ -3,9 +3,9 @@ require "tilt/erubi"
3
3
  require "erubi/capture_end"
4
4
 
5
5
  require "serbea/helpers"
6
- require "serbea/component_renderer"
7
6
  require "serbea/pipeline"
8
7
  require "serbea/template_engine"
8
+ require "serbea/component_renderer"
9
9
 
10
10
  module Tilt
11
11
  class SerbeaTemplate < ErubiTemplate
@@ -1,5 +1,9 @@
1
1
  module Serbea
2
2
  module Helpers
3
+ def self.included(mod)
4
+ Serbea::Pipeline.deny_value_method %i(prepend append)
5
+ end
6
+
3
7
  def capture(obj=nil)
4
8
  previous_buffer_state = @_erbout
5
9
  @_erbout = +""
@@ -21,5 +25,13 @@ module Serbea
21
25
  Erubi.h(input)
22
26
  end
23
27
  alias_method :escape, :h
28
+
29
+ def prepend(old_string, new_string)
30
+ "#{new_string}#{old_string}"
31
+ end
32
+
33
+ def append(old_string, new_string)
34
+ "#{old_string}#{new_string}"
35
+ end
24
36
  end
25
37
  end
@@ -10,19 +10,26 @@ module Serbea
10
10
  end
11
11
  end
12
12
 
13
+ def self.deny_value_method(name)
14
+ value_methods_denylist.merge Array(name)
15
+ end
16
+ def self.value_methods_denylist
17
+ @value_methods_denylist ||= Set.new
18
+ end
19
+
13
20
  def initialize(context, value)
14
21
  @context = context
15
22
  @value = value
16
23
  end
17
24
 
18
- def filter(sym, *aargs)
19
- if @value.respond_to?(sym)
20
- @value = @value.send(sym, *aargs)
21
- elsif @context.respond_to?(sym)
22
- @value = @context.send(sym, @value, *aargs)
25
+ def filter(name, *args)
26
+ if @value.respond_to?(name) && !self.class.value_methods_denylist.include?(name)
27
+ @value = @value.send(name, *args)
28
+ elsif @context.respond_to?(name)
29
+ @value = @context.send(name, @value, *args)
23
30
  else
24
- "Serbea warning: Filter not found: #{sym}".tap do |warning|
25
- raise_on_missing_filters ? raise(warning) : puts(warning)
31
+ "Serbea warning: Filter not found: #{name}".tap do |warning|
32
+ raise_on_missing_filters ? raise(warning) : STDERR.puts(warning)
26
33
  end
27
34
  end
28
35
 
@@ -56,7 +56,7 @@ module Serbea
56
56
  end
57
57
  end
58
58
 
59
- # Process the pipeline outputs
59
+ # Process any pipelines
60
60
  string = buff
61
61
  buff = ""
62
62
  until string.empty?
@@ -82,7 +82,15 @@ module Serbea
82
82
  end
83
83
  end
84
84
 
85
- # Process the render directives
85
+ # Process any directives
86
+ #
87
+ # TODO: allow custom directives! aka
88
+ # {%@something whatever %}
89
+ # {%@script
90
+ # const foo = "really? #{really}!"
91
+ # alert(foo.toLowerCase())
92
+ # %}
93
+ # {%@preact AwesomeChart data={#{ruby_data.to_json}} %}
86
94
  string = buff
87
95
  buff = ""
88
96
  until string.empty?
@@ -1,3 +1,3 @@
1
1
  module Serbea
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serbea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi