serbea 0.7.0 β†’ 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c69f1aa7916899c197489290d683afad319c66bccff8bd32d3e9a0e943bfa41
4
- data.tar.gz: 267760c9cbbc3cbde6af0a3479b905c4bd8eca6e601dee2d1bb43cb0a819aabd
3
+ metadata.gz: c5b809ec2d2de960b954c9d12d4bdfaaf1f910ff1f1e5aa7ac217db968cd1ac7
4
+ data.tar.gz: e819b84c2c0a33767f4d3736de70e916bfdd41fe354ba89a9f551172b22bdb41
5
5
  SHA512:
6
- metadata.gz: c50177a140769d470f500446902009faac98bb390ef44f7930ed28b3c1cb92ac0a499e15ee2c66384ef0c7a52e55dca892ff2c17fe3f85bc8022b92c2f1c6a6a
7
- data.tar.gz: 330296668991421be44b92b1a4a87470dc93ffd78e4b00530e26003fff1af293a9b4d51ee46fbcac2b541379a6e4c2a0179ec6365fafce14c219905ee8b73617
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. Le roi est mort, vive le roi!
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
 
@@ -4,7 +4,6 @@ require "tilt/erubi"
4
4
  require "serbea/helpers"
5
5
  require "serbea/pipeline"
6
6
  require "serbea/template_engine"
7
- require "serbea/component_renderer"
8
7
 
9
8
  module Tilt
10
9
  class SerbeaTemplate < ErubiTemplate
@@ -2,7 +2,6 @@
2
2
 
3
3
  # inspired by https://github.com/haml/haml/blob/main/lib/haml/plugin.rb
4
4
  module Serbea
5
-
6
5
  # This module makes Serbea work with Rails using the template handler API.
7
6
  class Plugin
8
7
  def handles_encoding?; true; end
@@ -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 << code.
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(code[2...-2])
94
- done = false
91
+ s = StringScanner.new($1)
95
92
  escaped_segment = ""
96
93
  segments = []
97
- while !done
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
- done = true
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(/{%@.*?%}/m)
152
+ text, code, string = string.partition(/{%@(.*?)%}/m)
164
153
 
165
154
  buff << text
166
155
  if code.length > 0
167
- code.sub!(/^\{%@/, "")
168
- code.sub!(/%}$/, "")
156
+ code = $1
169
157
  unless ["end", ""].include? code.strip
170
158
  original_line_length = code.lines.size
171
159
 
@@ -1,3 +1,3 @@
1
1
  module Serbea
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
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.7.0
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-10-31 00:00:00.000000000 Z
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