serbea 0.2.0 → 0.3.0
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 +4 -4
- data/lib/serbea/template_engine.rb +41 -1
- 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: 170e76b3b2d6c6024d9721f95831ebc85dd32fda2bca10f2471546bbc95cc5f7
|
4
|
+
data.tar.gz: 5dc3336c8549c6933325646f5a3fecdee6fec520393df8e141f86a3ef4b3f0ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8733456977f41a78a2e4a56bd8d25a4b737abdedf54d19cfbf7ad61f43a9edbbd422e1d81206205df366ef56d751567a87284de9c480887a79cefb0ae51ae1c
|
7
|
+
data.tar.gz: 57c097000a365d52fa0ee88ca8472957dccbfc898b2acb6d066f3fea49e865f94033cfcb30b9edc6585a1fb72ab191b524fb631c437b86a16c2a707e078b85ca
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module Serbea
|
2
2
|
class TemplateEngine < Erubi::CaptureEndEngine
|
3
3
|
FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze
|
4
|
+
|
5
|
+
def self.render_directive=(directive)
|
6
|
+
@render_directive = directive
|
7
|
+
end
|
8
|
+
def self.render_directive
|
9
|
+
@render_directive ||= "render"
|
10
|
+
end
|
4
11
|
|
5
12
|
def self.has_yaml_header?(template)
|
6
13
|
template.lines.first&.match? %r!\A---\s*\r?\n!
|
@@ -33,6 +40,7 @@ module Serbea
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
43
|
+
# Ensure the raw "tag" will strip out all ERB-style processing
|
36
44
|
until string.empty?
|
37
45
|
text, code, string = string.partition(/{% raw %}.*?{% endraw %}/m)
|
38
46
|
|
@@ -47,7 +55,8 @@ module Serbea
|
|
47
55
|
gsub("%}", "__RAW_END_EVAL__")
|
48
56
|
end
|
49
57
|
end
|
50
|
-
|
58
|
+
|
59
|
+
# Process the pipeline outputs
|
51
60
|
string = buff
|
52
61
|
buff = ""
|
53
62
|
until string.empty?
|
@@ -73,6 +82,37 @@ module Serbea
|
|
73
82
|
end
|
74
83
|
end
|
75
84
|
|
85
|
+
# Process the render directives
|
86
|
+
string = buff
|
87
|
+
buff = ""
|
88
|
+
until string.empty?
|
89
|
+
text, code, string = string.partition(/{%@.*?%}/m)
|
90
|
+
|
91
|
+
buff << text
|
92
|
+
if code.length > 0
|
93
|
+
code.sub! /^\{%@/, ""
|
94
|
+
code.sub! /%}$/, ""
|
95
|
+
unless ["end", ""].include? code.strip
|
96
|
+
pieces = code.split(" ")
|
97
|
+
if pieces[0].start_with?(/[A-Z]/) # Ruby class name
|
98
|
+
pieces[0].prepend " "
|
99
|
+
pieces[0] << ".new("
|
100
|
+
else # string or something else
|
101
|
+
pieces[0].prepend "("
|
102
|
+
end
|
103
|
+
if pieces.last == "do"
|
104
|
+
pieces.last.prepend ") "
|
105
|
+
buff << "{%:= #{self.class.render_directive}#{pieces.join(" ")} %}"
|
106
|
+
else
|
107
|
+
pieces.last << ")"
|
108
|
+
buff << "{%= #{self.class.render_directive}#{pieces.join(" ")} %}"
|
109
|
+
end
|
110
|
+
else
|
111
|
+
buff << "{%: end %}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
76
116
|
buff
|
77
117
|
end
|
78
118
|
|
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.
|
4
|
+
version: 0.3.0
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubi
|