handlebars_assets 0.9.0 → 0.10.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.
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +6 -1
- data/README.md +7 -4
- data/handlebars_assets.gemspec +1 -0
- data/lib/handlebars_assets/config.rb +9 -1
- data/lib/handlebars_assets/engine.rb +1 -0
- data/lib/handlebars_assets/tilt_handlebars.rb +17 -4
- data/lib/handlebars_assets/version.rb +1 -1
- data/test/handlebars_assets/slimbars_test.rb +28 -0
- metadata +20 -2
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
## On master
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.10.0 (2013-01-29)
|
4
|
+
|
5
|
+
* Support `.slimbars` extension for Slim templates - @davidlee
|
6
|
+
|
7
|
+
## 0.9.0 (2013-01-25)
|
4
8
|
|
5
9
|
* Update to [this commit](https://github.com/wycats/handlebars.js/commit/a3376e24b1a25f72cf86d1d999bd2ea93fa4dc39) of `handlebars.js`
|
6
10
|
* The hack that converted partial names to underscored paths (`shared/_time` -> `_shared_time`) is no longer necessary and has been removed. You should change all the partial references in your app when going to v0.9.x.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
handlebars_assets (0.
|
4
|
+
handlebars_assets (0.10.0)
|
5
5
|
execjs (>= 1.2.9)
|
6
6
|
sprockets (>= 2.0.3)
|
7
7
|
tilt
|
@@ -16,11 +16,15 @@ GEM
|
|
16
16
|
multi_json (1.4.0)
|
17
17
|
rack (1.4.1)
|
18
18
|
rake (10.0.3)
|
19
|
+
slim (1.3.6)
|
20
|
+
temple (~> 0.5.5)
|
21
|
+
tilt (~> 1.3.3)
|
19
22
|
sprockets (2.8.1)
|
20
23
|
hike (~> 1.2)
|
21
24
|
multi_json (~> 1.0)
|
22
25
|
rack (~> 1.0)
|
23
26
|
tilt (~> 1.1, != 1.3.0)
|
27
|
+
temple (0.5.5)
|
24
28
|
tilt (1.3.3)
|
25
29
|
|
26
30
|
PLATFORMS
|
@@ -30,3 +34,4 @@ DEPENDENCIES
|
|
30
34
|
haml
|
31
35
|
handlebars_assets!
|
32
36
|
rake
|
37
|
+
slim
|
data/README.md
CHANGED
@@ -10,11 +10,11 @@ Using `sprockets` with Sinatra or another framework? **handlebars_assets** works
|
|
10
10
|
|
11
11
|
My pull request to allow `/` in partials was pulled into Handlebars. The hack that converted partial names to underscored paths (`shared/_time` -> `_shared_time`) is no longer necessary and has been removed. You should change all the partial references in your app when going to v0.9.x.
|
12
12
|
|
13
|
-
## handlebars.js
|
13
|
+
## Edge version of handlebars.js
|
14
14
|
|
15
|
-
|
15
|
+
*Please read*
|
16
16
|
|
17
|
-
`handlebars_assets` is packaged with an edge build of `handlebars.js` (this [commit](https://github.com/wycats/handlebars.js/commit/a3376e24b1a25f72cf86d1d999bd2ea93fa4dc39). See the section on using another version if that does not work for you.
|
17
|
+
`handlebars_assets` is packaged with an edge build of `handlebars.js` (this [commit](https://github.com/wycats/handlebars.js/commit/a3376e24b1a25f72cf86d1d999bd2ea93fa4dc39)). See the section on using another version if that does not work for you.
|
18
18
|
|
19
19
|
## Installation with Rails 3.1+
|
20
20
|
|
@@ -118,7 +118,7 @@ simply turn on the config option
|
|
118
118
|
|
119
119
|
HandlebarsAssets::Config.ember = true
|
120
120
|
|
121
|
-
## `.hamlbars`
|
121
|
+
## `.hamlbars` and `.slimbars`
|
122
122
|
|
123
123
|
If you name your templates with the extension `.hamlbars`, you can use Haml syntax for your markup! Use `HandlebarsAssets::Config.haml_options` to pass custom options to the Haml rendering engine.
|
124
124
|
|
@@ -132,6 +132,8 @@ The Haml will be pre-processed so that the Handlebars template is basically this
|
|
132
132
|
<h1> {{title}} </h1>
|
133
133
|
<p> {{body}} </p>
|
134
134
|
|
135
|
+
The same applies to `.slimbars` and the Slim gem. Use `HandlebarsAssets::Config.slim_options` to pass custom options to the Slim rendering engine.
|
136
|
+
|
135
137
|
## Partials
|
136
138
|
|
137
139
|
If you begin the name of the template with an underscore, it will be recognized as a partial. You can invoke partials inside a template using the Handlebars partial syntax:
|
@@ -176,6 +178,7 @@ Follow me on [Github](https://github.com/leshill) and [Twitter](https://twitter.
|
|
176
178
|
* Blake Williams (@BlakeWilliams) : .handlebars extension
|
177
179
|
* Tristan Koch (@trkoch) : Strip leading whitespace from compiled templates
|
178
180
|
* Brian Cardarella (@bcardarella) : Ember support
|
181
|
+
* David Lee (@davidlee) : Slim support
|
179
182
|
|
180
183
|
# Contributing
|
181
184
|
|
data/handlebars_assets.gemspec
CHANGED
@@ -5,7 +5,7 @@ module HandlebarsAssets
|
|
5
5
|
module Config
|
6
6
|
extend self
|
7
7
|
|
8
|
-
attr_writer :compiler, :compiler_path, :ember, :haml_options, :known_helpers, :known_helpers_only, :options, :path_prefix, :template_namespace
|
8
|
+
attr_writer :compiler, :compiler_path, :ember, :haml_options, :known_helpers, :known_helpers_only, :options, :path_prefix, :slim_options, :template_namespace
|
9
9
|
|
10
10
|
def compiler
|
11
11
|
@compiler || 'handlebars.js'
|
@@ -43,6 +43,14 @@ module HandlebarsAssets
|
|
43
43
|
@path_prefix || 'templates'
|
44
44
|
end
|
45
45
|
|
46
|
+
def slim_available?
|
47
|
+
defined? ::Slim::Engine
|
48
|
+
end
|
49
|
+
|
50
|
+
def slim_options
|
51
|
+
@slim_options || {}
|
52
|
+
end
|
53
|
+
|
46
54
|
def template_namespace
|
47
55
|
@template_namespace || 'HandlebarsTemplates'
|
48
56
|
end
|
@@ -5,6 +5,7 @@ module HandlebarsAssets
|
|
5
5
|
app.assets.register_engine('.hbs', TiltHandlebars)
|
6
6
|
app.assets.register_engine('.handlebars', TiltHandlebars)
|
7
7
|
app.assets.register_engine('.hamlbars', TiltHandlebars) if HandlebarsAssets::Config.haml_available?
|
8
|
+
app.assets.register_engine('.slimbars', TiltHandlebars) if HandlebarsAssets::Config.slim_available?
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -23,7 +23,9 @@ module HandlebarsAssets
|
|
23
23
|
template_path = TemplatePath.new(scope)
|
24
24
|
|
25
25
|
source = if template_path.is_haml?
|
26
|
-
|
26
|
+
Haml::Engine.new(data, HandlebarsAssets::Config.haml_options).render
|
27
|
+
elsif template_path.is_slim?
|
28
|
+
Slim::Template.new(HandlebarsAssets::Config.slim_options) { data }.render
|
27
29
|
else
|
28
30
|
data
|
29
31
|
end
|
@@ -54,9 +56,16 @@ module HandlebarsAssets
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def initialize_engine
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
begin
|
60
|
+
require 'haml'
|
61
|
+
rescue LoadError
|
62
|
+
# haml not available
|
63
|
+
end
|
64
|
+
begin
|
65
|
+
require 'slim'
|
66
|
+
rescue LoadError
|
67
|
+
# slim not available
|
68
|
+
end
|
60
69
|
end
|
61
70
|
|
62
71
|
protected
|
@@ -73,6 +82,10 @@ module HandlebarsAssets
|
|
73
82
|
full_path.to_s.end_with?('.hamlbars')
|
74
83
|
end
|
75
84
|
|
85
|
+
def is_slim?
|
86
|
+
full_path.to_s.end_with?('.slimbars')
|
87
|
+
end
|
88
|
+
|
76
89
|
def is_partial?
|
77
90
|
template_path.gsub(%r{.*/}, '').start_with?('_')
|
78
91
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module HandlebarsAssets
|
4
|
+
class SlimbarsTest < Test::Unit::TestCase
|
5
|
+
include SprocketsScope
|
6
|
+
include CompilerSupport
|
7
|
+
|
8
|
+
def compile_slim(source)
|
9
|
+
Slim::Template.new(HandlebarsAssets::Config.slim_options) { source }.render
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
HandlebarsAssets::Config.reset!
|
14
|
+
HandlebarsAssets::Handlebars.reset!
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_render_slim
|
18
|
+
root = '/myapp/app/assets/templates'
|
19
|
+
file = 'test_render.slimbars'
|
20
|
+
scope = make_scope root, file
|
21
|
+
source = "p This is {{handlebars}}"
|
22
|
+
|
23
|
+
template = HandlebarsAssets::TiltHandlebars.new(scope.pathname.to_s) { source }
|
24
|
+
|
25
|
+
assert_equal hbs_compiled('test_render', compile_slim(source)), template.render(scope, {})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handlebars_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
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: 2013-01-
|
12
|
+
date: 2013-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
none: false
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: slim
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
none: false
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
none: false
|
94
110
|
description: Compile Handlebars templates in the Rails asset pipeline.
|
95
111
|
email:
|
96
112
|
- leshill@gmail.com
|
@@ -115,6 +131,7 @@ files:
|
|
115
131
|
- lib/handlebars_assets/version.rb
|
116
132
|
- test/edge/handlebars.js
|
117
133
|
- test/handlebars_assets/hamlbars_test.rb
|
134
|
+
- test/handlebars_assets/slimbars_test.rb
|
118
135
|
- test/handlebars_assets/tilt_edge_test.rb
|
119
136
|
- test/handlebars_assets/tilt_handlebars_test.rb
|
120
137
|
- test/test_helper.rb
|
@@ -147,6 +164,7 @@ summary: Compile Handlebars templates in the Rails asset pipeline.
|
|
147
164
|
test_files:
|
148
165
|
- test/edge/handlebars.js
|
149
166
|
- test/handlebars_assets/hamlbars_test.rb
|
167
|
+
- test/handlebars_assets/slimbars_test.rb
|
150
168
|
- test/handlebars_assets/tilt_edge_test.rb
|
151
169
|
- test/handlebars_assets/tilt_handlebars_test.rb
|
152
170
|
- test/test_helper.rb
|