brb-templates 0.1.0 → 0.1.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 +4 -4
- data/README.md +2 -2
- data/lib/brb/templates.rb +1 -0
- data/lib/brb/version.rb +1 -1
- data/lib/brb.rb +17 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e97cdefdd6b330fb27d992b001da7ce8da38972a53d0637c685e0cd49bfa984
|
4
|
+
data.tar.gz: b32f4fbeeeb03c988df6ff174f3f3678043d498c9421c0ff5de34b7a1c3b9545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a26f45b62b7d5e7649fca6086096ec65255179d33d81d26f2142da23b68dd5ba4c26d801bf88d85aa594afcceddc632db8df7d7eaa5f34184245bf1ceb35d8
|
7
|
+
data.tar.gz: 7ac2bb29e62e7bfb64dbce22dccfe8439203a8b8ff45a81d5d8c728da550a152a825981c70a4e9bc10ed28edef4313e2469f89c386b373164868052a5ca95ac6
|
data/README.md
CHANGED
@@ -91,11 +91,11 @@ Bundle BRB and call `BRB.enable` during your Rails app boot to use it.
|
|
91
91
|
|
92
92
|
Install the gem and add to the application's Gemfile by executing:
|
93
93
|
|
94
|
-
$ bundle add
|
94
|
+
$ bundle add brb-templates
|
95
95
|
|
96
96
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
97
97
|
|
98
|
-
$ gem install
|
98
|
+
$ gem install brb-templates
|
99
99
|
|
100
100
|
## Development
|
101
101
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "../brb"
|
data/lib/brb/version.rb
CHANGED
data/lib/brb.rb
CHANGED
@@ -13,7 +13,7 @@ module BRB
|
|
13
13
|
@logger = Logger.new "/dev/null"
|
14
14
|
def self.debug = @logger = Logger.new(STDOUT)
|
15
15
|
|
16
|
-
def self.enable = ActionView::Template::Handlers::ERB.erb_implementation = BRB::
|
16
|
+
def self.enable = ActionView::Template::Handlers::ERB.erb_implementation = BRB::Parser
|
17
17
|
|
18
18
|
module Sigil
|
19
19
|
def self.names = @values.keys
|
@@ -21,14 +21,27 @@ module BRB
|
|
21
21
|
|
22
22
|
def self.replace(scanner, key)
|
23
23
|
@values.fetch(key).then do |template|
|
24
|
-
|
25
|
-
|
24
|
+
case
|
25
|
+
when key == "t" && scanner.scan(/\.[\.\w]+/) then template.sub ":value", scanner.matched
|
26
|
+
when scanner.check(/\(/) then template.sub ":value", scan_arguments(scanner)
|
26
27
|
else
|
27
28
|
template
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
def self.scan_arguments(scanner)
|
34
|
+
arguments, open_parens = +"", 0
|
35
|
+
|
36
|
+
begin
|
37
|
+
arguments << scanner.scan_until(/\(|\)/)
|
38
|
+
open_parens += arguments.last == "(" ? 1 : -1
|
39
|
+
end until open_parens.zero?
|
40
|
+
|
41
|
+
arguments[1..-2]
|
42
|
+
end
|
43
|
+
|
44
|
+
|
32
45
|
def self.register(key, replacer)
|
33
46
|
@values[key.to_s] = replacer
|
34
47
|
end
|
@@ -45,7 +58,7 @@ module BRB
|
|
45
58
|
end_of_lorem
|
46
59
|
end
|
47
60
|
|
48
|
-
class
|
61
|
+
class Parser < ::ActionView::Template::Handlers::ERB::Erubi
|
49
62
|
def initialize(input, ...)
|
50
63
|
frontmatter = $1 if input.sub! /\A(.*?)~~~\n/m, ""
|
51
64
|
backmatter = $1 if input.sub! /~~~\n(.*?)\z/m, ""
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brb-templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- lib/brb.rb
|
54
|
+
- lib/brb/templates.rb
|
54
55
|
- lib/brb/version.rb
|
55
56
|
homepage: https://github.com/kaspth/brb
|
56
57
|
licenses:
|
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '0'
|
77
78
|
requirements: []
|
78
|
-
rubygems_version: 3.5.
|
79
|
+
rubygems_version: 3.5.4
|
79
80
|
signing_key:
|
80
81
|
specification_version: 4
|
81
82
|
summary: BRB is backslashed Ruby, a template system that lets you be-right-back to
|