tempeh 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/examples/advanced.tempeh +0 -1
- data/examples/basic.tempeh +7 -1
- data/lib/tempeh.rb +14 -4
- data/test/all.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c303f5b3f50f5fa4fd133911a2339c3f3abd300
|
4
|
+
data.tar.gz: 9dcc173c50c4ae67ba6d0a838ca62f4a917511f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c01c92e496791dfdf055409061a1b5007004faa20aecf6aa1ec70eab49f764dee0c364622bf85dff4b903c7f075c3312c7230d631350850bb53d37039cb00c81
|
7
|
+
data.tar.gz: 6b2e65109cc5b562af9bfb772874dc74b3c1db3defe44514b4395713bb5089e78d84d96dd30f34c39f0b5cebfafb2606c1e1ebdf0bdc214b26876ae9b90760f4
|
data/Gemfile.lock
CHANGED
data/examples/advanced.tempeh
CHANGED
data/examples/basic.tempeh
CHANGED
data/lib/tempeh.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Tempeh
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.3.0"
|
3
3
|
|
4
4
|
BLK_OPEN = "%"
|
5
5
|
|
@@ -36,7 +36,8 @@ module Tempeh
|
|
36
36
|
|
37
37
|
def compile(str)
|
38
38
|
terms = str.split(PATTERN)
|
39
|
-
|
39
|
+
|
40
|
+
parts = "proc { |args| __o = '';"
|
40
41
|
|
41
42
|
while (term = terms.shift)
|
42
43
|
case term
|
@@ -57,9 +58,18 @@ module Tempeh
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
61
|
+
def test
|
62
|
+
b = binding
|
63
|
+
p = proc { b.eval("a = 22") }
|
64
|
+
p.call
|
65
|
+
puts a
|
66
|
+
end
|
67
|
+
|
60
68
|
module Helpers
|
61
|
-
|
62
|
-
|
69
|
+
DEFAULT_ARGS = {}.freeze
|
70
|
+
|
71
|
+
def render(path, args = DEFAULT_ARGS)
|
72
|
+
instance_exec args, &tempeh_template_for(path)
|
63
73
|
end
|
64
74
|
|
65
75
|
def tempeh_template_for(path)
|
data/test/all.rb
CHANGED
@@ -49,6 +49,12 @@ test 'contextual rendering' do
|
|
49
49
|
assert_equal "bar", context.instance_eval(&template)
|
50
50
|
end
|
51
51
|
|
52
|
+
test 'passes optional `args` variable' do
|
53
|
+
template = Tempeh.compile("{{ args[:foo] }}")
|
54
|
+
|
55
|
+
assert_equal "bar", instance_exec({ foo: "bar" }, &template)
|
56
|
+
end
|
57
|
+
|
52
58
|
class View
|
53
59
|
include Tempeh::Helpers
|
54
60
|
|
@@ -66,11 +72,13 @@ setup do
|
|
66
72
|
end
|
67
73
|
|
68
74
|
test 'helpers' do |view|
|
69
|
-
path = './
|
75
|
+
path = './examples/basic.tempeh'
|
70
76
|
|
71
77
|
assert Tempeh.cache[path].nil?, 'template is already cached'
|
72
78
|
|
73
|
-
assert_equal
|
79
|
+
assert_equal "\n\nstevestevesteve", view.render(path)
|
74
80
|
|
75
81
|
assert Tempeh.cache[path], 'template was not cached'
|
82
|
+
|
83
|
+
assert_equal "\n\nnotstevenotstevenotsteve", view.render(path, name: 'notsteve')
|
76
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tempeh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Weiss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cutest
|