handlebars_assets 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +15 -11
- data/lib/handlebars_assets/engine.rb +1 -0
- data/lib/handlebars_assets/tilt_handlebars.rb +1 -1
- data/lib/handlebars_assets/version.rb +1 -1
- metadata +6 -6
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,11 +12,11 @@ Load `handlebars_assets` in your `Gemfile`
|
|
12
12
|
|
13
13
|
gem 'handlebars_assets'
|
14
14
|
|
15
|
-
Require `handlebars.js`
|
15
|
+
Require `handlebars.js` in your Javascript manifest (i.e. `application.js`)
|
16
16
|
|
17
17
|
//= require handlebars
|
18
18
|
|
19
|
-
#
|
19
|
+
# Compiling your Javascript templates in the asset pipeline
|
20
20
|
|
21
21
|
## Templates directory
|
22
22
|
|
@@ -24,11 +24,9 @@ You should located your templates under `app/assets/templates`. In your Javascri
|
|
24
24
|
|
25
25
|
//= require_tree ../templates
|
26
26
|
|
27
|
-
## Templates
|
28
|
-
|
29
27
|
## The template file
|
30
28
|
|
31
|
-
Write your Handlebars templates as standalone files in
|
29
|
+
Write your Handlebars templates as standalone files in your templates directory. Organize the templates similarly to Rails views.
|
32
30
|
|
33
31
|
For example, if you have new, edit, and show templates for a Contact model
|
34
32
|
|
@@ -38,18 +36,24 @@ For example, if you have new, edit, and show templates for a Contact model
|
|
38
36
|
edit.jst.hbs
|
39
37
|
show.jst.hbs
|
40
38
|
|
41
|
-
|
39
|
+
Your file extensions tell the asset pipeline how to process the file. Use `.hbs` to compile the template with Handlebars. Combine it with `.jst` to add the compiled template to the `JST` global variable.
|
40
|
+
|
41
|
+
If your file is `templates/contacts/new.jst.hbs`, the asset pipeline will generate Javascript code
|
42
|
+
|
43
|
+
1. Compile the Handlebars template to Javascript code
|
44
|
+
1. Add the template code to the `JST` global under the name `contacts/new`
|
45
|
+
|
46
|
+
You can then invoke the resulting template in your application's Javascript
|
42
47
|
|
43
|
-
|
44
|
-
1. Add the template to the `JST` global under the templates name
|
48
|
+
JST['contacts/new'](context);
|
45
49
|
|
46
50
|
## Partials
|
47
51
|
|
48
|
-
If you begin the name of the template with an underscore, it will be recognized as a partial. You can invoke partials using the Handlebars partial syntax:
|
52
|
+
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:
|
49
53
|
|
50
54
|
Invoke a {{> partial }}
|
51
55
|
|
52
|
-
**Important!** Handlebars does not understand nested partials and neither does this engine. No matter how nested, the partial is
|
56
|
+
**Important!** Handlebars does not understand nested partials and neither does this engine. No matter how nested, the partial is named from the asset's basename. The following will lead to much frustration (so don't do it :)
|
53
57
|
|
54
58
|
templates/
|
55
59
|
contacts/
|
@@ -67,7 +71,7 @@ Thank you Charles Lowell (@cowboyd) for [therubyracer](https://github.com/cowboy
|
|
67
71
|
|
68
72
|
# Contributing
|
69
73
|
|
70
|
-
Once you've made your great commits
|
74
|
+
Once you've made your great commits
|
71
75
|
|
72
76
|
1. Fork
|
73
77
|
1. Create a topic branch - git checkout -b my_branch
|
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.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: therubyracer
|
16
|
-
requirement: &
|
16
|
+
requirement: &70230656005660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70230656005660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tilt
|
27
|
-
requirement: &
|
27
|
+
requirement: &70230656005240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70230656005240
|
36
36
|
description: Compile Handlebars templates in the Rails asset pipeline.
|
37
37
|
email:
|
38
38
|
- leshill@gmail.com
|