hlt 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/hlt.rb +41 -14
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecdfac33c7dda8c7efc1d37f99ec0ce904b2c2a9
|
4
|
+
data.tar.gz: a31cf0421054fbeaa6548211e8d6d31610928b49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd9248c8e7d6577b67f1ecac69d5b82149fde2e54b7213fd2db194b07ecf51816cd2b76704ad2b4a2d91d7fc9b1eef0d748adfbcad7c4827aed4bbcfba1d173
|
7
|
+
data.tar.gz: c44ee8b315879205696319316548c441d8d61d183f7f1e52b0367984f6c897fa54d9e233a31fe98847a445de16f0a11ca161e97238b7b310bf149fb17190d19d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/hlt.rb
CHANGED
@@ -105,14 +105,19 @@ class Hlt
|
|
105
105
|
|
106
106
|
end
|
107
107
|
|
108
|
-
def render()
|
109
|
-
|
108
|
+
def render(locals: {})
|
109
|
+
|
110
|
+
variables = locals.map do |key, value|
|
111
|
+
"#{key} = locals['#{key}']"
|
112
|
+
end
|
113
|
+
|
110
114
|
s = "xml = RexleBuilder.new\n"
|
111
115
|
s << scanbuild(@doc.to_a)
|
112
|
-
|
116
|
+
|
117
|
+
a = eval variables.join("\n") + "\n" + s
|
113
118
|
|
114
119
|
Rexle.new(a).element('root/.').xml pretty: true
|
115
|
-
|
120
|
+
|
116
121
|
end
|
117
122
|
|
118
123
|
def to_doc()
|
@@ -223,37 +228,59 @@ class Hlt
|
|
223
228
|
%w{ th st nd rd th th th th th th }[n % 10] )
|
224
229
|
end
|
225
230
|
|
226
|
-
# under development 04-Nov-2015
|
227
231
|
|
232
|
+
def v(x)
|
233
|
+
|
234
|
+
if x then
|
235
|
+
var = x[/^=\s+(.*)/,1]
|
236
|
+
var ? var : x.inspect
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
228
241
|
def scanbuild(x, indent=0)
|
229
242
|
|
230
243
|
name, attributes, *remaining = x
|
231
|
-
|
244
|
+
|
232
245
|
children = remaining.shift
|
233
246
|
text = ''
|
234
247
|
|
235
248
|
|
236
249
|
if children.is_a? Array then
|
237
250
|
nested = scanbuild(children, indent+1)
|
238
|
-
|
251
|
+
elsif children
|
239
252
|
text = children
|
240
253
|
end
|
241
254
|
|
242
255
|
pad = ' ' * indent
|
243
|
-
|
256
|
+
|
257
|
+
|
244
258
|
s2 = if children.is_a? Array then
|
245
|
-
|
259
|
+
if name == 'templatecode' then
|
260
|
+
"%s%s" % [pad, text]
|
261
|
+
else
|
262
|
+
"%sxml.%s(%s,%s) do\n%s" % \
|
263
|
+
[pad, name, attributes.to_s, v(text), nested]
|
264
|
+
end
|
246
265
|
else
|
247
|
-
|
266
|
+
if name == 'templatecode' then
|
267
|
+
"%s%s" % [pad, text]
|
268
|
+
else
|
269
|
+
' ' * indent + "xml.%s(%s,%s)" % [name, attributes.to_s, v(text)]
|
270
|
+
end
|
248
271
|
end
|
249
272
|
|
250
|
-
|
251
|
-
|
273
|
+
while remaining.any? do
|
274
|
+
children = remaining.shift
|
275
|
+
if children and children.is_a? Array then
|
276
|
+
s2 << "\n" + scanbuild(children, indent+1)
|
277
|
+
end
|
252
278
|
end
|
253
279
|
|
254
|
-
s2 << "\n%send" % [pad] if children.is_a?(Array)
|
280
|
+
s2 << "\n%send" % [pad] if children.is_a?(Array) or name == 'templatecode'
|
255
281
|
|
256
282
|
s2
|
257
283
|
end
|
258
284
|
|
259
|
-
|
285
|
+
|
286
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|