haml_coffee_assets 1.11.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -8
- data/lib/haml_coffee_assets/rails/engine.rb +14 -10
- data/lib/haml_coffee_assets/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Haml Coffee Assets [![Build Status](https://secure.travis-ci.org/netzpirat/haml_coffee_assets.png)](http://travis-ci.org/netzpirat/haml_coffee_assets)
|
2
2
|
|
3
|
-
Haml Coffee Assets compiles [Haml Coffee](https://github.com/netzpirat/haml-coffee) templates in the Rails 3.1 asset
|
3
|
+
Haml Coffee Assets compiles [Haml Coffee](https://github.com/netzpirat/haml-coffee) templates in the Rails 3.1 asset
|
4
|
+
pipeline, so you can use them as JavaScript templates in your JavaScript heavy Rails application. Server-side rendering
|
5
|
+
of templates is also possible, allowing you to share the same template files for Rails and JavaScript templates. It also
|
6
|
+
works as a pure [Sprockets](https://github.com/sstephenson/sprockets) engine without Rails.
|
4
7
|
|
5
8
|
Tested on MRI Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest version of JRuby.
|
6
9
|
|
@@ -93,8 +96,8 @@ removed.
|
|
93
96
|
When you give your templates the extension `.jst.hamlc`, Haml Coffee Assets will only generate the template function,
|
94
97
|
which then in turn will be further processed by the
|
95
98
|
[Sprocket JST processor](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/jst_processor.rb). Because
|
96
|
-
Haml Coffee Assets will not generate the template, you can't use the AMD support, template name filter and the JST
|
97
|
-
definition is more cumbersome compared to the Haml Coffee template generation.
|
99
|
+
Haml Coffee Assets will not generate the template, you can't use the AMD support, template name filter and the JST
|
100
|
+
namespace definition is more cumbersome compared to the Haml Coffee template generation.
|
98
101
|
|
99
102
|
With this approach you should place all your Haml Coffee templates in the `app/assets/templates` directory and include
|
100
103
|
all templates from your `app/assets/javascripts/application.js.coffee`:
|
@@ -108,7 +111,10 @@ with `templates/`, which may be not what you want.
|
|
108
111
|
|
109
112
|
### Server-side rendering in Rails
|
110
113
|
|
111
|
-
Haml Coffee Assets registers the `.hamlc` extension with Action View, so that Rails templates can be written in Haml
|
114
|
+
Haml Coffee Assets registers the `.hamlc` extension with Action View, so that Rails templates can be written in Haml
|
115
|
+
Coffee. Rails will see templates placed in `app/assets/javascripts/templates` (though this path can be changed if you
|
116
|
+
store your templates in another directory), and the same template files can be rendered via Rails or via JavaScript on
|
117
|
+
the client. Server-side rendering is only available when using the global placement and not with the AMD placement.
|
112
118
|
|
113
119
|
Given a Haml Coffee template at `app/assets/javascripts/templates/books/_book.hamlc`:
|
114
120
|
|
@@ -134,7 +140,9 @@ Require and render the same file on the client using the asset pipeline:
|
|
134
140
|
JST["books/book"](name: "A Tale of Two Cities", author: "Charles Dickens")
|
135
141
|
```
|
136
142
|
|
137
|
-
Note that the template is required as `books/_book` because it refers to the actual file, but the template name on the
|
143
|
+
Note that the template is required as `books/_book` because it refers to the actual file, but the template name on the
|
144
|
+
client is simply `books/book`. If you require all templates at once with `#= require_tree ./templates`, you won't need
|
145
|
+
to remember this distinction.
|
138
146
|
|
139
147
|
## Configuration
|
140
148
|
|
@@ -456,7 +464,8 @@ for more information about each helper function.
|
|
456
464
|
|
457
465
|
### Shared template path
|
458
466
|
|
459
|
-
Rails will look for templates in `app/assets/javascripts/templates` when rendering on the server side. If you store your
|
467
|
+
Rails will look for templates in `app/assets/javascripts/templates` when rendering on the server side. If you store your
|
468
|
+
templates in another directory, you can change this location:
|
460
469
|
|
461
470
|
```ruby
|
462
471
|
config.hamlcoffee.shared_template_path = "custom/template/path"
|
@@ -509,8 +518,8 @@ example.
|
|
509
518
|
|
510
519
|
Developed by Michael Kessler, [mksoft.ch](https://mksoft.ch).
|
511
520
|
|
512
|
-
If you like Haml Coffee Assets, you can watch the repository at [GitHub](https://github.com/netzpirat/haml_coffee_assets)
|
513
|
-
follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project updates.
|
521
|
+
If you like Haml Coffee Assets, you can watch the repository at [GitHub](https://github.com/netzpirat/haml_coffee_assets)
|
522
|
+
and follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project updates.
|
514
523
|
|
515
524
|
## Development
|
516
525
|
|
@@ -17,16 +17,20 @@ module HamlCoffeeAssets
|
|
17
17
|
initializer 'sprockets.hamlcoffeeassets', :group => :all, :after => 'sprockets.environment' do |app|
|
18
18
|
require 'haml_coffee_assets/action_view/template_handler'
|
19
19
|
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
# No server side template support with AMD
|
21
|
+
if ::HamlCoffeeAssets.config.placement == 'global'
|
22
|
+
|
23
|
+
# Register Tilt template (for ActionView)
|
24
|
+
ActiveSupport.on_load(:action_view) do
|
25
|
+
::ActionView::Template.register_template_handler(:hamlc, ::HamlCoffeeAssets::ActionView::TemplateHandler)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Add template path to ActionController's view paths.
|
29
|
+
ActiveSupport.on_load(:action_controller) do
|
30
|
+
path = ::HamlCoffeeAssets.config.shared_template_path
|
31
|
+
resolver = ::HamlCoffeeAssets::ActionView::Resolver.new(path)
|
32
|
+
::ActionController::Base.append_view_path(resolver)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
next unless app.assets
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_coffee_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.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: 2013-01-
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coffee-script
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: 1.3.6
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project: haml_coffee_assets
|
120
|
-
rubygems_version: 1.8.
|
120
|
+
rubygems_version: 1.8.24
|
121
121
|
signing_key:
|
122
122
|
specification_version: 3
|
123
123
|
summary: Haml CoffeeScript templates
|