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 +4 -4
- data/lib/serbea.rb +1 -1
- data/lib/serbea/helpers.rb +12 -0
- data/lib/serbea/pipeline.rb +14 -7
- data/lib/serbea/template_engine.rb +10 -2
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdeba2843c805f483e3514fbceaa63d610ac9b436762b8ff7c34ae6f7f6d8c3a
|
4
|
+
data.tar.gz: 325e190e80f4cc5cd777e824c512361a71435b482672c1da8d17bf4ffc4d639c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfa7787a1ed422c4e1e238f2f328c37586e65d1bcc11458e6650803d8d6bfc21a6204bbdd6fa5e038b15e2120d43d08ef9a327e2ff25500e7bd569078d11a0e
|
7
|
+
data.tar.gz: b8789ea01c5eb34aed8ceb0d770b94401d6a7167d0fca38d9892ca79d4be7681b30705fb96061e31a9f52aaf5babaa9af4fa57921cab665c63f414bf286408ae
|
data/lib/serbea.rb
CHANGED
@@ -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
|
data/lib/serbea/helpers.rb
CHANGED
@@ -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
|
data/lib/serbea/pipeline.rb
CHANGED
@@ -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(
|
19
|
-
if @value.respond_to?(
|
20
|
-
@value = @value.send(
|
21
|
-
elsif @context.respond_to?(
|
22
|
-
@value = @context.send(
|
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: #{
|
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
|
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
|
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?
|
data/lib/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubi
|