ltdtemplate 0.1.2 → 0.1.3
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.
- data/HISTORY.txt +3 -0
- data/TEMPLATE_MANUAL.html +31 -25
- data/ltdtemplate.gemspec +3 -3
- metadata +4 -4
data/HISTORY.txt
CHANGED
data/TEMPLATE_MANUAL.html
CHANGED
@@ -11,7 +11,7 @@ td:first-child, th:first-child { padding-left: 0.3em }
|
|
11
11
|
</head>
|
12
12
|
<body>
|
13
13
|
<h1 id='top'>LtdTemplate Manual<br>
|
14
|
-
<span style='font-size: smaller'>Version 0.1.
|
14
|
+
<span style='font-size: smaller'>Version 0.1.3; July 13, 2013</span></h1>
|
15
15
|
|
16
16
|
<h2>Author(s)</h2>
|
17
17
|
|
@@ -34,11 +34,15 @@ Kappa Computer Solutions, LLC (original author)</li>
|
|
34
34
|
<h2 id='introduction'>Introduction</h2>
|
35
35
|
|
36
36
|
<p><a href='http://rubygems.org/gems/ltdtemplate'>LtdTemplate</a> is a
|
37
|
-
<a href='http://rugybems.org/'>Ruby Gem</a> implementing resource-limitable
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
<a href='http://rugybems.org/'>Ruby Gem</a> implementing resource-limitable,
|
38
|
+
user-editable, textual templating.</p>
|
39
|
+
|
40
|
+
<p>Note that "user-editable" does not particularly refer to simplicity
|
41
|
+
(understanding most templates will be facilitated by having a programming
|
42
|
+
background), but rather that, with proper configuration, it can be used to
|
43
|
+
allow sophisticated users to edit their own templates (e.g. for message
|
44
|
+
localization) with limited risk of infinite execution loops or recursion,
|
45
|
+
excessively long strings, or other uncontrolled resource utilization.</p>
|
42
46
|
|
43
47
|
<p>This document describes the template syntax. See the Gem documentation
|
44
48
|
for information about the programming interface.</p>
|
@@ -96,7 +100,7 @@ themselves.</p>
|
|
96
100
|
<li><a href='#assignment_syntax'>Assignments</a></li>
|
97
101
|
<li><a href='#predefined_vars'>Pre-Defined Variables</a></li>
|
98
102
|
<li><a href='#codeseq_syntax'>Code Sequences</a></li>
|
99
|
-
<li><a href='#
|
103
|
+
<li><a href='#codeblock_syntax'>Code Blocks</a></li>
|
100
104
|
<li><a href='#subscript_syntax'>Subscripts And Code-Block Bindings</a></li>
|
101
105
|
</ul>
|
102
106
|
|
@@ -286,7 +290,7 @@ the parent namespace (if they do not already exist) and variables beginning
|
|
286
290
|
with at-sign (<code>@</code>) will be created in the root namespace. All
|
287
291
|
others will be created in the current namespace.</p>
|
288
292
|
|
289
|
-
<p>See also the <a href='#
|
293
|
+
<p>See also the <a href='#namespace_var_method'>var</a> method for
|
290
294
|
<a href='#namespace_values'>namespaces</a>.</p>
|
291
295
|
|
292
296
|
<p>[<a href='#contents'>Contents</a>] [<a href='#code_syntax'>Template Code Syntax</a>]</p>
|
@@ -302,7 +306,7 @@ others will be created in the current namespace.</p>
|
|
302
306
|
<tr><td><code>$</code></td>
|
303
307
|
<td>This is the current <a href='#namespace_values'>namespace</a>. A
|
304
308
|
new namespace is automatically created each time a
|
305
|
-
<a href='#
|
309
|
+
<a href='#codeblock_syntax'>code block</a> is executed and is
|
306
310
|
destroyed when the code block completes.</td></tr>
|
307
311
|
|
308
312
|
<tr><td><code>^</code></td>
|
@@ -314,8 +318,9 @@ others will be created in the current namespace.</p>
|
|
314
318
|
"top-level") namespace.</td></tr>
|
315
319
|
|
316
320
|
<tr><td><code>_</code></td>
|
317
|
-
<td>This variable
|
318
|
-
|
321
|
+
<td>This variable refers to the array of positional and/or named
|
322
|
+
parameters passed into the template or current
|
323
|
+
<a href='#codeblock_syntax'>code block</a>.</td></tr>
|
319
324
|
|
320
325
|
</table>
|
321
326
|
|
@@ -325,8 +330,8 @@ others will be created in the current namespace.</p>
|
|
325
330
|
|
326
331
|
<p>A code sequence refers to a sequence of zero or more template code
|
327
332
|
expressions. <a href='#template_syntax'>Templates</a>,
|
328
|
-
<a href='#call_syntax'>method call</a> parameters, and
|
329
|
-
are all code sequences.</p>
|
333
|
+
<a href='#call_syntax'>method call</a> parameters, and
|
334
|
+
<a href='#codeblock_syntax'>code block</a> bodies are all code sequences.</p>
|
330
335
|
|
331
336
|
<p>If a code sequence consists of a single, non-string value and does
|
332
337
|
not constitute the entire template code, it is retained as-is. Otherwise,
|
@@ -343,10 +348,10 @@ produce the result of the code sequence.</p>
|
|
343
348
|
|
344
349
|
<h3 id='codeblock_syntax'>Code Blocks</h3>
|
345
350
|
|
346
|
-
<p>If you surround a <a href='#
|
351
|
+
<p>If you surround a <a href='#codeseq_syntax'>code sequence</a>
|
347
352
|
by braces (<code>{</code> and <code>}</code>), you create a code
|
348
353
|
block. A code block is a value which does not render directly, but
|
349
|
-
can be called as a <a href='#
|
354
|
+
can be called as a <a href='#call_syntax'>method call</a>, executing
|
350
355
|
the code sequence within the code block.</p>
|
351
356
|
|
352
357
|
<blockquote><code>render_method=({ $.method })<br>
|
@@ -370,11 +375,11 @@ array_var */<br>
|
|
370
375
|
array_var['items][5] /* as above - alternate syntax */</code></blockquote>
|
371
376
|
|
372
377
|
<p>If the requested item does not exist, the special value
|
373
|
-
"<a href='#
|
378
|
+
"<a href='#nil_value'>nil</a>" is used instead.</p>
|
374
379
|
|
375
380
|
<p>LtdTemplate also uses subscript syntax to bind
|
376
|
-
<a href='#
|
377
|
-
subsequently be called like <a href='#
|
381
|
+
<a href='#codeblock_syntax'>code blocks</a> to non-array values. These can
|
382
|
+
subsequently be called like <a href='#call_syntax'>methods</a>. They
|
378
383
|
never override standard methods.</p>
|
379
384
|
|
380
385
|
<blockquote><code>x['greeting]=({'hello}) /* where x is not an array
|
@@ -405,8 +410,8 @@ $.*(1, 2, 3).list /* => 1, 2, 3 */</code></blockquote>
|
|
405
410
|
|
406
411
|
<p>LtdTemplate does not have array literals, but you can construct arrays
|
407
412
|
using the variable assignment method (see <a href='#variable_syntax'>variable
|
408
|
-
syntax</a>) or via the <a href='#
|
409
|
-
|
413
|
+
syntax</a>) or via the <a href='#namespace_array_method'>array</a> method
|
414
|
+
on <a href='#namespace_values'>namespaces</a>:</p>
|
410
415
|
|
411
416
|
<blockquote><code>empty=() /* empty array */ single=(10 ..) /* one element */
|
412
417
|
double=(5, 10) /* two */<br>
|
@@ -566,10 +571,11 @@ programming environments.</p>
|
|
566
571
|
|
567
572
|
<tr><th>Method</th><th>Description</th></tr>
|
568
573
|
|
569
|
-
<tr><td><code>array(</code><i>elements</i><code>)</code>,
|
574
|
+
<tr><td id='namespace_array_method'><code>array(</code><i>elements</i><code>)</code>,
|
570
575
|
<code>*(</code><i>elements</i><code>)</code></td>
|
571
576
|
<td>Returns an anonymous array (see <a href='#array_values'>array
|
572
|
-
values</a>
|
577
|
+
values</a>, <a href='#assignment_syntax'>assignments</a>, and
|
578
|
+
the <a href='#namespace_var_method'>var</a> method)</td></tr>
|
573
579
|
|
574
580
|
<tr><td><code>false</code></td><td>Returns the boolean false value</td></tr>
|
575
581
|
|
@@ -611,7 +617,7 @@ programming environments.</p>
|
|
611
617
|
<tr><td><code>use(</code><i>name</i><code>)</code></td>
|
612
618
|
<td>Calls the template loader to load resource <i>name</i></td></tr>
|
613
619
|
|
614
|
-
<tr><td id='
|
620
|
+
<tr><td id='namespace_var_method'><code>var(</code><i>name_1</i><code>,</code> ...<code>,</code>
|
615
621
|
<i>name_N</i> <code>..</code> <i>set_1</i><code>,</code>
|
616
622
|
<i>value_1</i><code>,</code> ...<code>,</code> <i>set_N</i><code>,</code>
|
617
623
|
<i>value_N</i><code>)</code></td>
|
@@ -672,9 +678,9 @@ for the nil value as follows:</p>
|
|
672
678
|
integer</td></tr>
|
673
679
|
|
674
680
|
<tr><td><code>flt, float</code></td><td>Returns the number as a
|
675
|
-
floating-point number</td></tr>
|
681
|
+
floating-point (decimal) number</td></tr>
|
676
682
|
|
677
|
-
<tr><td><code>int</code></td><td>Returns the
|
683
|
+
<tr><td><code>int</code></td><td>Returns the integer portion of the number</td></tr>
|
678
684
|
|
679
685
|
<tr><td><code>str</code>, <code>string</code></td>
|
680
686
|
<td>Returns the number as a string</td></tr>
|
data/ltdtemplate.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ltdtemplate"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.3"
|
4
4
|
s.date = "2013-07-13"
|
5
5
|
s.authors = ["Brian Katzung"]
|
6
6
|
s.email = ["briank@kappacs.com"]
|
7
7
|
s.homepage = "http://rubygems.org/gems/ltdtemplate"
|
8
|
-
s.summary = "A
|
9
|
-
s.description = "A
|
8
|
+
s.summary = "A resource-limitable, textual templating system"
|
9
|
+
s.description = "A resource-limitable, user-editable, textual templating system"
|
10
10
|
s.license = "MIT"
|
11
11
|
|
12
12
|
s.files = Dir.glob("lib/**/*") +
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brian Katzung
|
@@ -18,7 +18,7 @@ date: 2013-07-13 00:00:00 -05:00
|
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description: A
|
21
|
+
description: A resource-limitable, user-editable, textual templating system
|
22
22
|
email:
|
23
23
|
- briank@kappacs.com
|
24
24
|
executables: []
|
@@ -85,7 +85,7 @@ rubyforge_project:
|
|
85
85
|
rubygems_version: 1.3.7
|
86
86
|
signing_key:
|
87
87
|
specification_version: 3
|
88
|
-
summary: A
|
88
|
+
summary: A resource-limitable, textual templating system
|
89
89
|
test_files:
|
90
90
|
- test/00class.rb
|
91
91
|
- test/04number.rb
|