mote 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/bin/mote +17 -6
- data/lib/mote.rb +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -61,7 +61,7 @@ As with control instructions, it happens naturally:
|
|
61
61
|
The values passed to the template are available as local variables:
|
62
62
|
|
63
63
|
```ruby
|
64
|
-
example = Mote.parse("Hello {{name}}")
|
64
|
+
example = Mote.parse("Hello {{name}}", self, [:name])
|
65
65
|
assert_equal "Hello world", example.call(name: "world")
|
66
66
|
assert_equal "Hello Bruno", example.call(name: "Bruno")
|
67
67
|
```
|
data/bin/mote
CHANGED
@@ -7,33 +7,44 @@ NAME
|
|
7
7
|
mote -- Minimum Operational Template
|
8
8
|
|
9
9
|
SYNOPSIS
|
10
|
-
mote FILE
|
10
|
+
mote FILE [param1 value1 ... paramN valueN]
|
11
11
|
|
12
12
|
DESCRIPTION
|
13
13
|
Use this command line tool to render mote templates. The result
|
14
14
|
is redirected to standard output.
|
15
15
|
|
16
|
+
The extra parameters supplied will be passed to the template.
|
17
|
+
Note that all the parameter values will be treated as strings.
|
18
|
+
|
16
19
|
EXAMPLES
|
17
|
-
If your template called foo.mote, you can render it with the
|
20
|
+
If your template is called foo.mote, you can render it with the
|
18
21
|
following command:
|
19
22
|
|
20
23
|
mote foo.mote
|
21
24
|
|
22
|
-
To
|
25
|
+
To write the result to a new file, just redirect the output:
|
23
26
|
|
24
27
|
mote foo.mote > foo.html
|
25
28
|
|
29
|
+
If the template uses a local variable `bar`, you can pass a
|
30
|
+
value from the command line:
|
31
|
+
|
32
|
+
mote foo.mote bar 42
|
33
|
+
|
26
34
|
SEE ALSO
|
27
35
|
https://github.com/soveran/mote
|
28
36
|
EOS
|
29
37
|
|
30
|
-
if ARGV.
|
38
|
+
if ARGV.size.even?
|
31
39
|
puts help
|
32
40
|
exit
|
33
41
|
end
|
34
42
|
|
35
|
-
|
43
|
+
t = ARGV.shift
|
44
|
+
p = Hash[*ARGV]
|
45
|
+
|
46
|
+
require_relative "../lib/mote"
|
36
47
|
|
37
48
|
include Mote::Helpers
|
38
49
|
|
39
|
-
print mote(
|
50
|
+
print mote(t, p)
|
data/lib/mote.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
class Mote
|
21
|
-
VERSION = "1.1.
|
21
|
+
VERSION = "1.1.1"
|
22
22
|
|
23
23
|
PATTERN = /^(\n+)|^\s*(%)\s*(.*?)\n|(<\?)\s+(.*?)\s+\?>|(\{\{)(.*?)\}\}/m
|
24
24
|
|
@@ -28,7 +28,7 @@ class Mote
|
|
28
28
|
parts = "Proc.new do |params, __o|\n params ||= {}; __o ||= ''\n"
|
29
29
|
|
30
30
|
vars.each do |var|
|
31
|
-
parts << "%s = params[
|
31
|
+
parts << "%s = params[%s]\n" % [var, var.inspect]
|
32
32
|
end
|
33
33
|
|
34
34
|
while term = terms.shift
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cutest
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152186380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152186380
|
25
25
|
description: Mote is a very simple and fast template engine.
|
26
26
|
email:
|
27
27
|
- michel@soveran.com
|