dusty_rails_renderer 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/lib/dusty_rails_renderer.rb +20 -11
- data/lib/dusty_rails_renderer/version.rb +1 -1
- 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: 3a7a87a9c6e48e30eaee29a20b233da9035004f6
|
4
|
+
data.tar.gz: 1c6572ee4ce940d8236a411a86d9a3d91558750b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63b16c797ead4428da1bc8e66213929d06b29867b3bb72e270a6faa9c4ec7de9113f50dfa145c4adc0eadcd45caff017d7309f91a950ab2582f18b01ea20c326
|
7
|
+
data.tar.gz: 08edb04fdc10acd6fa9c061ad2034d93ece983336ab43f7f9d117cda82a6f94a63da9df3be3f63af821433ad669fbe6f17812e4be4ecac2bf8c95fcabbde8ddb
|
data/lib/dusty_rails_renderer.rb
CHANGED
@@ -13,7 +13,12 @@ module DustyRailsRenderer
|
|
13
13
|
@precompiled_templates = Hash.new
|
14
14
|
@last_modification_hash = Hash.new
|
15
15
|
@context = V8::Context.new
|
16
|
-
@context.eval(@dust_library, 'dustjs')
|
16
|
+
@context.eval(@dust_library, 'dustjs')
|
17
|
+
|
18
|
+
if self.configuration.load_dust_helpers
|
19
|
+
@dust_helpers = File.read(self.configuration.dust_js_helper_path)
|
20
|
+
@context.eval(@dust_helpers, 'dustjs-helpers')
|
21
|
+
end
|
17
22
|
|
18
23
|
read_dust_files
|
19
24
|
end
|
@@ -27,16 +32,16 @@ module DustyRailsRenderer
|
|
27
32
|
@precompiled_templates.to_json
|
28
33
|
end
|
29
34
|
|
30
|
-
def render(template_name, json)
|
35
|
+
def render(template_name, json)
|
31
36
|
if self.configuration.production
|
32
37
|
@context.eval("(function() { var result; dust.render('#{template_name}', #{json}, function(err, out) { result = out; }); return result; })()")
|
33
|
-
else
|
38
|
+
else
|
34
39
|
read_dust_files
|
35
40
|
@context.eval("(function() { var result; dust.render('#{template_name}', #{json}, function(err, out) { result = out; }); return result; })()")
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
|
-
private
|
44
|
+
private
|
40
45
|
#Read in and register Dust.js templates
|
41
46
|
def read_dust_files
|
42
47
|
@dust_config.each do |template, info|
|
@@ -66,10 +71,10 @@ module DustyRailsRenderer
|
|
66
71
|
|
67
72
|
@context.eval("dust.loadSource(\"#{escaped_template}\")")
|
68
73
|
@precompiled_templates[template_name] = template[0]
|
69
|
-
else
|
74
|
+
else
|
70
75
|
contents = File.read(file_url).gsub("\n","").gsub("\"","'").gsub("\t","")
|
71
|
-
template = @context.eval("(function() {var template = dust.compile(\"#{contents}\",'#{template_name}'); dust.loadSource(template); return template; })()")
|
72
|
-
|
76
|
+
template = @context.eval("(function() {var template = dust.compile(\"#{contents}\",'#{template_name}'); dust.loadSource(template); return template; })()")
|
77
|
+
|
73
78
|
if self.configuration.logging
|
74
79
|
puts "compiled template = #{escaped_template}"
|
75
80
|
end
|
@@ -77,9 +82,9 @@ module DustyRailsRenderer
|
|
77
82
|
@precompiled_templates[template_name] = template
|
78
83
|
end
|
79
84
|
end
|
80
|
-
end
|
85
|
+
end
|
81
86
|
end
|
82
|
-
|
87
|
+
|
83
88
|
def self.configure
|
84
89
|
yield(configuration)
|
85
90
|
end
|
@@ -96,15 +101,19 @@ module DustyRailsRenderer
|
|
96
101
|
attr_accessor :node_dust_compiler
|
97
102
|
attr_accessor :logging
|
98
103
|
attr_accessor :dust_compiler_command
|
99
|
-
|
104
|
+
attr_accessor :load_dust_helpers
|
105
|
+
attr_accessor :dust_js_helper_path
|
106
|
+
|
100
107
|
def initialize
|
101
108
|
@dust_config_path = "config/dust_initializer.yml"
|
102
109
|
@dust_js_library_path = "app/assets/javascripts/libraries/dust/dust-full.js"
|
103
110
|
@dust_template_base_path = "app/assets/javascripts/dust/"
|
104
|
-
@production = false
|
111
|
+
@production = false
|
105
112
|
@node_dust_compiler = false
|
106
113
|
@dust_compiler_command = "dustc"
|
107
114
|
@logging = false
|
115
|
+
@load_dust_helpers = false
|
116
|
+
@dust_js_helper_path = "app/assets/javascripts/libraries/dust/dust-helpers.js"
|
108
117
|
end
|
109
118
|
end
|
110
119
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dusty_rails_renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Ellis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|