jadeite 0.0.8 → 0.0.9
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/lib/jadeite/environment.rb +10 -17
- data/lib/jadeite/version.rb +1 -1
- data/lib/nodejs/builtins.rb +3 -0
- metadata +3 -3
data/lib/jadeite/environment.rb
CHANGED
@@ -27,18 +27,18 @@ module Jadeite
|
|
27
27
|
node_env = NodeJS::Environment.new(@context, File.expand_path('../../', __FILE__))
|
28
28
|
@context['jade'] = node_env.require('jade-runtime').runtime
|
29
29
|
@jade = node_env.require('jade')
|
30
|
+
|
31
|
+
# Create a new object in V8 that will keep a cached copy of compiled templates
|
32
|
+
@cache = @context['Object'].new
|
30
33
|
end
|
31
34
|
|
32
35
|
def compile(template_str, opts={})
|
33
36
|
opts = compile_options.merge(opts)
|
34
37
|
compiled = if cache?
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
else
|
40
|
-
@jade.compile(template_str.strip, compile_options.merge(opts))
|
41
|
-
end
|
38
|
+
cached_read(template_str, opts) { @jade.compile(template_str, opts) }
|
39
|
+
else
|
40
|
+
@jade.compile(template_str.strip, compile_options.merge(opts))
|
41
|
+
end
|
42
42
|
Template.new(compiled)
|
43
43
|
end
|
44
44
|
|
@@ -69,16 +69,9 @@ module Jadeite
|
|
69
69
|
private
|
70
70
|
|
71
71
|
def cached_read(template_str, opts, &blk)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
else
|
76
|
-
File.open(cache_file, "w") do |f|
|
77
|
-
cached = "(#{blk.call});"
|
78
|
-
f.write(cached)
|
79
|
-
cached
|
80
|
-
end
|
81
|
-
end
|
72
|
+
key = Digest::MD5.hexdigest("#{template_str}#{opts.inspect}")
|
73
|
+
@cache[key] = blk.call unless @cache[key]
|
74
|
+
@cache[key]
|
82
75
|
end
|
83
76
|
end
|
84
77
|
|
data/lib/jadeite/version.rb
CHANGED
data/lib/nodejs/builtins.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jadeite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: therubyracer
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project: jadeite
|
124
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.24
|
125
125
|
signing_key:
|
126
126
|
specification_version: 3
|
127
127
|
summary: Jadeite lets you compile and render Jade templates from your Ruby code. Under
|