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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- handlebars_assets (0.0.1)
4
+ handlebars_assets (0.0.3)
5
5
  therubyracer
6
6
  tilt
7
7
 
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` to your Javascript manifest (i.e. `application.js`)
15
+ Require `handlebars.js` in your Javascript manifest (i.e. `application.js`)
16
16
 
17
17
  //= require handlebars
18
18
 
19
- # Using Handlebars for your Javascript templates
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 the location specified in your Javascript manifest. Organize the templates similarly to your Rails views. Name your files with `.jst.hbs` to add them to the `JST` global for your Javascript.
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
- Based on the extensions, the asset pipeline will generate a Javascript asset for each file
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
- 1. Compile the Handlebars template to Javascript
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 always named on the basename. The following will lead to much frustration (so don't do it :)
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
@@ -1,6 +1,7 @@
1
1
  module HandlebarsAssets
2
2
  class Engine < ::Rails::Engine
3
3
  initializer "sprockets.handlebars", after: "sprockets.environment" do |app|
4
+ next unless app.assets
4
5
  app.assets.register_engine('.hbs', TiltHandlebars)
5
6
  end
6
7
  end
@@ -8,7 +8,7 @@ module HandlebarsAssets
8
8
 
9
9
  def evaluate(scope, locals, &block)
10
10
  name = basename(scope.logical_path)
11
- compiled_hbs = Handlebars.precompile data
11
+ compiled_hbs = Handlebars.precompile(data)
12
12
 
13
13
  if name.starts_with?('_')
14
14
  partial_name = name[1..-1].inspect
@@ -1,3 +1,3 @@
1
1
  module HandlebarsAssets
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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.0.2
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-08-26 00:00:00.000000000Z
12
+ date: 2011-09-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: therubyracer
16
- requirement: &70186767769060 !ruby/object:Gem::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: *70186767769060
24
+ version_requirements: *70230656005660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tilt
27
- requirement: &70186767768640 !ruby/object:Gem::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: *70186767768640
35
+ version_requirements: *70230656005240
36
36
  description: Compile Handlebars templates in the Rails asset pipeline.
37
37
  email:
38
38
  - leshill@gmail.com