serbea 0.7.0 β 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/serbea.rb +0 -1
- data/lib/serbea/rails_support.rb +0 -1
- data/lib/serbea/template_engine.rb +9 -21
- data/lib/version.rb +1 -1
- metadata +2 -3
- data/lib/serbea/component_renderer.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5b809ec2d2de960b954c9d12d4bdfaaf1f910ff1f1e5aa7ac217db968cd1ac7
|
4
|
+
data.tar.gz: e819b84c2c0a33767f4d3736de70e916bfdd41fe354ba89a9f551172b22bdb41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b3ab77eed51511959586f271ff814e094c6ef4fb4278dc60d85b92dafec4a328a084e27359c7626b661dea18e4e4f6007bceb40b4780557e1454752ed95d27
|
7
|
+
data.tar.gz: ff277d2b7471f668586248e0524429c8380ca30322f5b698bdf44b094a4cd7a202dfdfd3a87a7d1de3b652140eaf5d9e285f1addeb632e79e4be96b83e2e415b
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
π Serbea: Similar to ERB, Except Awesomer
|
1
|
+
# π Serbea: Similar to ERB, Except Awesomer
|
2
2
|
|
3
|
-
The Ruby template language you always dreamed of is here.
|
3
|
+
The Ruby template language you've always dreamed of is finally here. _Le roi est mort, vive le roi!_
|
4
4
|
|
5
5
|
Serbea combines the best ideas from "brace-style" template languages such as Liquid, Nunjucks, Twig, Jinja, Mustache, etc.βand applies them to the world of ERB. You can use Serbea in Rails application, Bridgetown static sites, or pretty much any Ruby scenario you could imagine.
|
6
6
|
|
data/lib/serbea.rb
CHANGED
data/lib/serbea/rails_support.rb
CHANGED
@@ -66,13 +66,11 @@ module Serbea
|
|
66
66
|
|
67
67
|
# Ensure the raw "tag" will strip out all ERB-style processing
|
68
68
|
until string.empty?
|
69
|
-
text, code, string = string.partition(/{% raw %}.*?{% endraw %}/m)
|
69
|
+
text, code, string = string.partition(/{% raw %}(.*?){% endraw %}/m)
|
70
70
|
|
71
71
|
buff << text
|
72
72
|
if code.length > 0
|
73
|
-
buff <<
|
74
|
-
sub("{% raw %}", "").
|
75
|
-
sub("{% endraw %}", "").
|
73
|
+
buff << $1.
|
76
74
|
gsub("{{", "__RAW_START_PRINT__").
|
77
75
|
gsub("}}", "__RAW_END_PRINT__").
|
78
76
|
gsub("{%", "__RAW_START_EVAL__").
|
@@ -84,17 +82,16 @@ module Serbea
|
|
84
82
|
string = buff
|
85
83
|
buff = ""
|
86
84
|
until string.empty?
|
87
|
-
text, code, string = string.partition(/{{.*?}}/m)
|
85
|
+
text, code, string = string.partition(/{{(.*?)}}/m)
|
88
86
|
|
89
87
|
buff << text
|
90
88
|
if code.length > 0
|
91
89
|
original_line_length = code.lines.size
|
92
90
|
|
93
|
-
s = StringScanner.new(
|
94
|
-
done = false
|
91
|
+
s = StringScanner.new($1)
|
95
92
|
escaped_segment = ""
|
96
93
|
segments = []
|
97
|
-
|
94
|
+
until s.eos?
|
98
95
|
portion = s.scan_until(/\|>?/)
|
99
96
|
if portion
|
100
97
|
if portion.end_with?('\|')
|
@@ -124,7 +121,7 @@ module Serbea
|
|
124
121
|
# or just the rest will do
|
125
122
|
segments << s.rest
|
126
123
|
end
|
127
|
-
|
124
|
+
s.terminate
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
@@ -148,24 +145,15 @@ module Serbea
|
|
148
145
|
end
|
149
146
|
end
|
150
147
|
|
151
|
-
# Process any directives
|
152
|
-
#
|
153
|
-
# TODO: allow custom directives! aka
|
154
|
-
# {%@something whatever %}
|
155
|
-
# {%@script
|
156
|
-
# const foo = "really? #{really}!"
|
157
|
-
# alert(foo.toLowerCase())
|
158
|
-
# %}
|
159
|
-
# {%@preact AwesomeChart data={#{ruby_data.to_json}} %}
|
148
|
+
# Process any render directives
|
160
149
|
string = buff
|
161
150
|
buff = ""
|
162
151
|
until string.empty?
|
163
|
-
text, code, string = string.partition(/{
|
152
|
+
text, code, string = string.partition(/{%@(.*?)%}/m)
|
164
153
|
|
165
154
|
buff << text
|
166
155
|
if code.length > 0
|
167
|
-
code
|
168
|
-
code.sub!(/%}$/, "")
|
156
|
+
code = $1
|
169
157
|
unless ["end", ""].include? code.strip
|
170
158
|
original_line_length = code.lines.size
|
171
159
|
|
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.7.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- Rakefile
|
79
79
|
- lib/serbea.rb
|
80
80
|
- lib/serbea/bridgetown_support.rb
|
81
|
-
- lib/serbea/component_renderer.rb
|
82
81
|
- lib/serbea/helpers.rb
|
83
82
|
- lib/serbea/pipeline.rb
|
84
83
|
- lib/serbea/rails_support.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Serbea
|
2
|
-
class ComponentRenderer
|
3
|
-
include Helpers
|
4
|
-
|
5
|
-
def initialize(variables = {})
|
6
|
-
@variables = variables
|
7
|
-
end
|
8
|
-
|
9
|
-
def respond_to_missing?(key, include_private = false)
|
10
|
-
@variables.key?(key)
|
11
|
-
end
|
12
|
-
|
13
|
-
def method_missing(key)
|
14
|
-
return @variables[key] if respond_to_missing?(key)
|
15
|
-
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|