hogan_assets 1.3.0 → 1.3.1
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 +4 -0
- data/Gemfile.lock +3 -1
- data/README.md +5 -4
- data/hogan_assets.gemspec +2 -0
- data/lib/hogan_assets/tilt.rb +4 -6
- data/lib/hogan_assets/version.rb +1 -1
- data/test/hogan_assets/tilt_test.rb +23 -8
- metadata +18 -2
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hogan_assets (1.3.
|
4
|
+
hogan_assets (1.3.1)
|
5
5
|
execjs (>= 1.2.9)
|
6
6
|
sprockets (>= 2.0.3)
|
7
7
|
tilt (>= 1.3.3)
|
@@ -11,6 +11,7 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
execjs (1.4.0)
|
13
13
|
multi_json (~> 1.0)
|
14
|
+
haml (3.1.6)
|
14
15
|
hike (1.2.1)
|
15
16
|
multi_json (1.3.5)
|
16
17
|
rack (1.4.1)
|
@@ -25,4 +26,5 @@ PLATFORMS
|
|
25
26
|
ruby
|
26
27
|
|
27
28
|
DEPENDENCIES
|
29
|
+
haml
|
28
30
|
hogan_assets!
|
data/README.md
CHANGED
@@ -91,10 +91,11 @@ I made this because I <3 **mustache** and want to use it in Rails. Follow me on
|
|
91
91
|
|
92
92
|
# Contributors
|
93
93
|
|
94
|
-
* @mdavidn (Matthew Nelson)
|
95
|
-
* @ajacksified (Jack Lawson)
|
96
|
-
* @mikesmullin (Mike Smullin)
|
97
|
-
* @gleuch (Greg Leuch)
|
94
|
+
* @mdavidn (Matthew Nelson) : Remove unnecessary template source
|
95
|
+
* @ajacksified (Jack Lawson) : Configurable file extension
|
96
|
+
* @mikesmullin (Mike Smullin) : hamstache support
|
97
|
+
* @gleuch (Greg Leuch) : Mustache lambdas
|
98
|
+
* @lautis (Ville Lautanala) : hamstache fix
|
98
99
|
|
99
100
|
## Contributing
|
100
101
|
|
data/hogan_assets.gemspec
CHANGED
data/lib/hogan_assets/tilt.rb
CHANGED
@@ -11,16 +11,14 @@ module HoganAssets
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def evaluate(scope, locals, &block)
|
14
|
-
text =
|
15
|
-
|
16
|
-
if scope.pathname.extname == '.hamstache'
|
14
|
+
text = if scope.pathname.extname == '.hamstache'
|
17
15
|
raise "Unable to complile #{scope.pathname} because haml is not available. Did you add the haml gem?" unless HoganAssets::Config.haml_available?
|
18
|
-
|
19
|
-
compiled_template = Hogan.compile(source)
|
16
|
+
Haml::Engine.new(data, @options).render
|
20
17
|
else
|
21
|
-
|
18
|
+
data
|
22
19
|
end
|
23
20
|
|
21
|
+
compiled_template = Hogan.compile(text)
|
24
22
|
template_name = scope.logical_path.inspect
|
25
23
|
|
26
24
|
# Only emit the source template if we are using lambdas
|
data/lib/hogan_assets/version.rb
CHANGED
@@ -2,12 +2,16 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module HoganAssets
|
4
4
|
class TiltTest < Test::Unit::TestCase
|
5
|
-
def scope
|
6
|
-
Class.new do
|
7
|
-
|
5
|
+
def scope(path)
|
6
|
+
instance = Class.new do
|
7
|
+
attr_accessor :_path
|
8
8
|
|
9
|
-
def
|
9
|
+
def logical_path ; _path.gsub /\..*/, '' ; end
|
10
|
+
|
11
|
+
def pathname ; Pathname.new _path ; end
|
10
12
|
end.new
|
13
|
+
instance._path = path
|
14
|
+
instance
|
11
15
|
end
|
12
16
|
|
13
17
|
def test_mime_type
|
@@ -15,17 +19,28 @@ module HoganAssets
|
|
15
19
|
end
|
16
20
|
|
17
21
|
def test_render
|
18
|
-
|
19
|
-
|
22
|
+
path = 'path/to/template.mustache'
|
23
|
+
template = HoganAssets::Tilt.new(path) { "This is {{mustache}}" }
|
24
|
+
assert_equal <<-END_EXPECTED, template.render(scope(path), {})
|
20
25
|
this.HoganTemplates || (this.HoganTemplates = {});
|
21
26
|
this.HoganTemplates[\"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, {});
|
22
27
|
END_EXPECTED
|
23
28
|
end
|
24
29
|
|
30
|
+
def test_hamstache_render
|
31
|
+
path = 'path/to/template.hamstache'
|
32
|
+
template = HoganAssets::Tilt.new(path) { "%p This is {{hamstache}}" }
|
33
|
+
assert_equal <<-END_EXPECTED, template.render(scope(path), {})
|
34
|
+
this.HoganTemplates || (this.HoganTemplates = {});
|
35
|
+
this.HoganTemplates[\"path/to/template\"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||\"\");t.b(\"<p>This is \");t.b(t.v(t.f(\"hamstache\",c,p,0)));t.b(\"</p>\");t.b(\"\\n\");return t.fl(); },partials: {}, subs: { }}, \"\", Hogan, {});
|
36
|
+
END_EXPECTED
|
37
|
+
end
|
38
|
+
|
25
39
|
def test_render_with_lambdas
|
40
|
+
path = 'path/to/template.mustache'
|
26
41
|
HoganAssets::Config.lambda_support = true
|
27
|
-
template = HoganAssets::Tilt.new(
|
28
|
-
assert_equal <<-END_EXPECTED, template.render(scope, {})
|
42
|
+
template = HoganAssets::Tilt.new(path) { "This is {{mustache}}" }
|
43
|
+
assert_equal <<-END_EXPECTED, template.render(scope(path), {})
|
29
44
|
this.HoganTemplates || (this.HoganTemplates = {});
|
30
45
|
this.HoganTemplates[\"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: { }}, "This is {{mustache}}", Hogan, {});
|
31
46
|
END_EXPECTED
|
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.1
|
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-06-
|
12
|
+
date: 2012-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.0.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: haml
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: Use compiled hogan.js (mustache) JavaScript templates with sprockets
|
63
79
|
and the Rails asset pipeline.
|
64
80
|
email:
|