hogan_assets 1.3.2 → 1.3.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/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +16 -5
- data/lib/hogan_assets/config.rb +5 -1
- data/lib/hogan_assets/tilt.rb +3 -2
- data/lib/hogan_assets/version.rb +1 -1
- data/test/hogan_assets/tilt_test.rb +15 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
## 1.3.3 (2012-09-10)
|
|
2
|
+
|
|
3
|
+
* Use `HoganAssets::Config.template_namespace` to use a custom namespace for your templates - @adamstrickland
|
|
4
|
+
|
|
1
5
|
## 1.3.2 (2012-08-04)
|
|
2
6
|
|
|
3
|
-
* Use `HoganAssets::Config.
|
|
7
|
+
* Use `HoganAssets::Config.path_prefix` to strip a common path prefix from your template names
|
|
4
8
|
|
|
5
9
|
## 1.3.1 (2012-06-21)
|
|
6
10
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -85,6 +85,16 @@ will give you a compiled template:
|
|
|
85
85
|
|
|
86
86
|
*TODO* Can this be done in a nicer way?
|
|
87
87
|
|
|
88
|
+
### Template namespace
|
|
89
|
+
|
|
90
|
+
You can change the namespace for the generated templates. By default, the
|
|
91
|
+
namespace is `HoganTemplates`. To change it, use the `template_namespace`
|
|
92
|
+
option. For example:
|
|
93
|
+
|
|
94
|
+
HoganAssets::Config.configure do |config|
|
|
95
|
+
config.template_namespace = 'JST'
|
|
96
|
+
end
|
|
97
|
+
|
|
88
98
|
### Template Extensions
|
|
89
99
|
|
|
90
100
|
By default, templates are recognized if they have an extension of `.mustache` (and if you have haml available, `.hamstache`.) You can change the template extensions by setting the `template_extensions` configuration option in an initializer:
|
|
@@ -105,11 +115,12 @@ I made this because I <3 **mustache** and want to use it in Rails. Follow me on
|
|
|
105
115
|
|
|
106
116
|
# Contributors
|
|
107
117
|
|
|
108
|
-
* @mdavidn
|
|
109
|
-
* @ajacksified
|
|
110
|
-
* @mikesmullin
|
|
111
|
-
* @gleuch
|
|
112
|
-
* @lautis
|
|
118
|
+
* @mdavidn (Matthew Nelson) : Remove unnecessary template source
|
|
119
|
+
* @ajacksified (Jack Lawson) : Configurable file extension
|
|
120
|
+
* @mikesmullin (Mike Smullin) : hamstache support
|
|
121
|
+
* @gleuch (Greg Leuch) : Mustache lambdas
|
|
122
|
+
* @lautis (Ville Lautanala) : hamstache fix
|
|
123
|
+
* @adamstrickland (Adam Strickland) : Custom template namespace
|
|
113
124
|
|
|
114
125
|
## Contributing
|
|
115
126
|
|
data/lib/hogan_assets/config.rb
CHANGED
|
@@ -14,7 +14,7 @@ module HoganAssets
|
|
|
14
14
|
module Config
|
|
15
15
|
extend self
|
|
16
16
|
|
|
17
|
-
attr_writer :lambda_support, :path_prefix, :template_extensions
|
|
17
|
+
attr_writer :lambda_support, :path_prefix, :template_extensions, :template_namespace
|
|
18
18
|
|
|
19
19
|
def configure
|
|
20
20
|
yield self
|
|
@@ -32,6 +32,10 @@ module HoganAssets
|
|
|
32
32
|
@path_prefix ||= 'templates'
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def template_namespace
|
|
36
|
+
@template_namespace ||= 'HoganTemplates'
|
|
37
|
+
end
|
|
38
|
+
|
|
35
39
|
def template_extensions
|
|
36
40
|
@template_extensions ||= if haml_available?
|
|
37
41
|
['mustache', 'hamstache']
|
data/lib/hogan_assets/tilt.rb
CHANGED
|
@@ -12,6 +12,7 @@ module HoganAssets
|
|
|
12
12
|
|
|
13
13
|
def evaluate(scope, locals, &block)
|
|
14
14
|
template_path = TemplatePath.new scope
|
|
15
|
+
template_namespace = HoganAssets::Config.template_namespace
|
|
15
16
|
|
|
16
17
|
text = if template_path.is_hamstache?
|
|
17
18
|
raise "Unable to complile #{template_path.full_path} because haml is not available. Did you add the haml gem?" unless HoganAssets::Config.haml_available?
|
|
@@ -26,8 +27,8 @@ module HoganAssets
|
|
|
26
27
|
# Only emit the source template if we are using lambdas
|
|
27
28
|
text = '' unless HoganAssets::Config.lambda_support?
|
|
28
29
|
<<-TEMPLATE
|
|
29
|
-
this
|
|
30
|
-
this
|
|
30
|
+
this.#{template_namespace} || (this.#{template_namespace} = {});
|
|
31
|
+
this.#{template_namespace}[#{template_path.name}] = new Hogan.Template(#{compiled_template}, #{text.inspect}, Hogan, {});
|
|
31
32
|
TEMPLATE
|
|
32
33
|
end
|
|
33
34
|
|
data/lib/hogan_assets/version.rb
CHANGED
|
@@ -75,5 +75,20 @@ module HoganAssets
|
|
|
75
75
|
this.HoganTemplates[\"template\"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||\"\");t.b(\"This is \");t.b(t.v(t.f(\"mustache\",c,p,0)));return t.fl(); },partials: {}, subs: { }}, "", Hogan, {});
|
|
76
76
|
END_EXPECTED
|
|
77
77
|
end
|
|
78
|
+
|
|
79
|
+
def test_template_namespace
|
|
80
|
+
HoganAssets::Config.configure do |config|
|
|
81
|
+
config.template_namespace = 'JST'
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.mustache'
|
|
85
|
+
|
|
86
|
+
template = HoganAssets::Tilt.new(scope.s_path) { "This is {{mustache}}" }
|
|
87
|
+
|
|
88
|
+
assert_equal <<-END_EXPECTED, template.render(scope, {})
|
|
89
|
+
this.JST || (this.JST = {});
|
|
90
|
+
this.JST[\"path/to/template\"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||\"\");t.b(\"This is \");t.b(t.v(t.f(\"mustache\",c,p,0)));return t.fl(); },partials: {}, subs: { }}, "", Hogan, {});
|
|
91
|
+
END_EXPECTED
|
|
92
|
+
end
|
|
78
93
|
end
|
|
79
94
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hogan_assets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
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: 2012-
|
|
12
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: execjs
|