xrb 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
- checksums.yaml.gz.sig +0 -0
- data/bake/xrb/parsers.rb +17 -20
- data/ext/Makefile +270 -0
- data/ext/XRB_Extension.bundle +0 -0
- data/ext/escape.o +0 -0
- data/ext/extconf.h +5 -0
- data/ext/markup.o +0 -0
- data/ext/mkmf.log +122 -0
- data/ext/query.o +0 -0
- data/ext/tag.o +0 -0
- data/ext/template.o +0 -0
- data/ext/xrb/markup.c +241 -241
- data/ext/xrb/query.c +69 -69
- data/ext/xrb/template.c +93 -93
- data/ext/xrb.o +0 -0
- data/lib/xrb/builder.rb +13 -6
- data/lib/xrb/entities.xrb +4 -19
- data/lib/xrb/fallback/markup.rb +1618 -1619
- data/lib/xrb/fallback/markup.rl +0 -1
- data/lib/xrb/fallback/query.rb +515 -515
- data/lib/xrb/fallback/template.rb +787 -787
- data/lib/xrb/parsers.rb +0 -1
- data/lib/xrb/template.rb +8 -44
- data/lib/xrb/version.rb +1 -1
- data/readme.md +6 -1
- data.tar.gz.sig +0 -0
- metadata +12 -3
- metadata.gz.sig +0 -0
- data/lib/xrb/parse_delegate.rb +0 -19
data/lib/xrb/parsers.rb
CHANGED
data/lib/xrb/template.rb
CHANGED
@@ -46,13 +46,13 @@ module XRB
|
|
46
46
|
def initialize(encoding: Encoding::UTF_8)
|
47
47
|
@code = String.new.force_encoding(encoding)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
attr :code
|
51
|
-
|
51
|
+
|
52
52
|
# Output raw text to the template.
|
53
53
|
def text(text)
|
54
54
|
text = text.gsub("'", "\\\\'")
|
55
|
-
@code << "#{OUT}
|
55
|
+
@code << "#{OUT}.raw('#{text}');"
|
56
56
|
|
57
57
|
# This is an interesting approach, but it doens't preserve newlines or tabs as raw characters, so template line numbers don't match up.
|
58
58
|
# @parts << "#{OUT}<<#{text.dump};"
|
@@ -64,9 +64,8 @@ module XRB
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Output a string interpolation.
|
67
|
-
def expression(
|
68
|
-
|
69
|
-
@code << "#{OUT}<<String(#{text});"
|
67
|
+
def expression(code)
|
68
|
+
@code << "#{OUT}<<(#{code});"
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
@@ -93,11 +92,11 @@ module XRB
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def to_string(scope = Object.new, output = nil)
|
96
|
-
output
|
95
|
+
builder = Builder.new(output, encoding: code.encoding)
|
97
96
|
|
98
|
-
scope.instance_exec(
|
97
|
+
scope.instance_exec(builder, &to_proc)
|
99
98
|
|
100
|
-
return output
|
99
|
+
return builder.output
|
101
100
|
end
|
102
101
|
|
103
102
|
def to_buffer(scope)
|
@@ -110,10 +109,6 @@ module XRB
|
|
110
109
|
|
111
110
|
protected
|
112
111
|
|
113
|
-
def output_buffer
|
114
|
-
String.new.force_encoding(code.encoding)
|
115
|
-
end
|
116
|
-
|
117
112
|
def code
|
118
113
|
@code ||= compile!
|
119
114
|
end
|
@@ -130,35 +125,4 @@ module XRB
|
|
130
125
|
assembler.code
|
131
126
|
end
|
132
127
|
end
|
133
|
-
|
134
|
-
class MarkupTemplate < Template
|
135
|
-
class Assembler < Template::Assembler
|
136
|
-
# Output a string interpolation.
|
137
|
-
def expression(code)
|
138
|
-
@code << "#{OUT}<<(#{code});"
|
139
|
-
end
|
140
|
-
|
141
|
-
# Output raw text to the template.
|
142
|
-
def text(text)
|
143
|
-
text = text.gsub("'", "\\\\'")
|
144
|
-
@code << "#{OUT}.raw('#{text}');"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def to_string(scope = Object.new, output = nil)
|
149
|
-
super.output
|
150
|
-
end
|
151
|
-
|
152
|
-
protected
|
153
|
-
|
154
|
-
# We need an assembler which builds specific `Markup.append` sequences.
|
155
|
-
def make_assembler
|
156
|
-
Assembler.new
|
157
|
-
end
|
158
|
-
|
159
|
-
# The output of the markup template is encoded markup (e.g. with entities, tags, etc).
|
160
|
-
def output_buffer
|
161
|
-
Builder.new(encoding: code.encoding)
|
162
|
-
end
|
163
|
-
end
|
164
128
|
end
|
data/lib/xrb/version.rb
CHANGED
data/readme.md
CHANGED
@@ -6,9 +6,14 @@ XRB is a templating system built loosely on top of XHTML markup. It uses efficie
|
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
+
Please see the [project documentation](https://socketry.github.io/xrb/) for more details.
|
10
|
+
|
11
|
+
- [Usage](https://socketry.github.io/xrb/guides/getting-started/index) - This guide gives a brief overview of the XRB templating system and how to use it.
|
12
|
+
|
9
13
|
## See Also
|
10
14
|
|
11
|
-
- [xrb-vscode](https://github.com/socketry/xrb-vscode) package for Visual Studio Code.
|
15
|
+
- [xrb-vscode](https://github.com/socketry/xrb-vscode) - A syntax highlighting package for Visual Studio Code.
|
16
|
+
- [trenni](https://github.com/ioquatix/trenni) - The original templating system which XRB is based on.
|
12
17
|
|
13
18
|
## Contributing
|
14
19
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
40
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
41
|
-----END CERTIFICATE-----
|
42
|
-
date: 2024-04-
|
42
|
+
date: 2024-04-27 00:00:00.000000000 Z
|
43
43
|
dependencies: []
|
44
44
|
description:
|
45
45
|
email:
|
@@ -50,7 +50,17 @@ extra_rdoc_files: []
|
|
50
50
|
files:
|
51
51
|
- bake/xrb/entities.rb
|
52
52
|
- bake/xrb/parsers.rb
|
53
|
+
- ext/Makefile
|
54
|
+
- ext/XRB_Extension.bundle
|
55
|
+
- ext/escape.o
|
56
|
+
- ext/extconf.h
|
53
57
|
- ext/extconf.rb
|
58
|
+
- ext/markup.o
|
59
|
+
- ext/mkmf.log
|
60
|
+
- ext/query.o
|
61
|
+
- ext/tag.o
|
62
|
+
- ext/template.o
|
63
|
+
- ext/xrb.o
|
54
64
|
- ext/xrb/escape.c
|
55
65
|
- ext/xrb/escape.h
|
56
66
|
- ext/xrb/markup.c
|
@@ -80,7 +90,6 @@ files:
|
|
80
90
|
- lib/xrb/fallback/template.rl
|
81
91
|
- lib/xrb/markup.rb
|
82
92
|
- lib/xrb/native.rb
|
83
|
-
- lib/xrb/parse_delegate.rb
|
84
93
|
- lib/xrb/parsers.rb
|
85
94
|
- lib/xrb/query.rb
|
86
95
|
- lib/xrb/reference.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/xrb/parse_delegate.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2016-2024, by Samuel Williams.
|
5
|
-
|
6
|
-
module XRB
|
7
|
-
# This is a sample delegate for capturing all events. It's only use is for testing.
|
8
|
-
class ParseDelegate
|
9
|
-
def initialize
|
10
|
-
@events = []
|
11
|
-
end
|
12
|
-
|
13
|
-
attr :events
|
14
|
-
|
15
|
-
def method_missing(*args)
|
16
|
-
@events << args
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|