haml_assets 0.0.5 → 0.1.0

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
- haml_assets (0.0.5)
4
+ haml_assets (0.1.0)
5
5
  haml
6
6
  tilt
7
7
 
data/README.md CHANGED
@@ -1,58 +1,56 @@
1
- # Use haml to write your Javascript templates
1
+ **BREAKING CHANGE** `haml_assets` now works with the `haml` gem. Please update
2
+ your gemfile.
2
3
 
3
- *ALPHA*
4
+ # Use `haml` to write your JavaScript templates in the asset pipeline
4
5
 
5
- Writing Javascript templates for Backbone.js (or other frameworks) in your app? Would you like to use haml and the asset pipeline?
6
+ Writing JavaScript templates for Backbone.js (or other frameworks) in your app?
7
+ Would you like to use `haml` in the asset pipeline?
6
8
 
7
- This gem adds haml templating support to the Rails 3.1 asset pipeline. This gem works with the EJS gem and JST asset engine to make your haml available as a compiled Javascript template.
9
+ This gem adds `haml` support to the Rails 3.1 asset pipeline. You will also
10
+ need a gem that creates a compiled JavaScript template like `hogan_assets` or
11
+ `handlebars_assets` as well.
8
12
 
9
13
  ## Installing
10
14
 
11
15
  Add this to your `Gemfile`
12
16
 
13
17
  gem 'haml_assets'
14
- gem 'ejs'
15
- gem 'haml', :git => 'https://github.com/infbio/haml.git', :branch => 'form_for_fix'
16
-
17
- There is a catastrophic form_for bug in the haml gem. Use our fork until it is fixed. Check our fork for details.
18
-
19
- # Using haml for your Javascript templates
20
18
 
19
+ # Using `haml` for your JavaScript templates
21
20
 
22
21
  ## Templates directory
23
22
 
24
- You should located your templates under `app/assets`; we suggest `app/assets/templates`. In your Javascript manifest file (for example `application.js`), use `require_tree`
23
+ You should located your templates under `app/assets`; we suggest
24
+ `app/assets/templates`. In your JavaScript manifest file (for example
25
+ `application.js`), use `require_tree`
25
26
 
26
27
  //= require_tree ../templates
27
28
 
28
29
  ## The template file
29
30
 
30
- Inside your templates directory, add your template file. The file should be named as follows
31
+ Inside your templates directory, add your template file. The file should be
32
+ named as follows
31
33
 
32
- your_template_name.jst.ejs.haml
34
+ your_template_name.mustache.haml
33
35
 
34
- The asset pipeline will then generate the actual Javascript asset
36
+ The asset pipeline will then generate the actual JavaScript asset
35
37
 
36
38
  1. Convert your haml to HTML
37
- 1. Compile the HTML to an EJS Javascript template
38
- 1. Add the template to the JST global under the templates name
39
-
40
- **Important!** The asset pipeline is not invoking a controller to generate the templates. If you are using existing view templates, you may have to edit templates to remove some references to controller helpers.
39
+ 1. Compile the HTML to an mustache Javascript template using `hogan_assets`
41
40
 
42
- ## EJS
43
-
44
- In your template file you can use the EJS delimiters as you would normally. If you want to use them in attributes mark the attribute html_safe.
45
-
46
- = f.text_field :email, class: 'text', value: '<%= email %>'.html_safe
41
+ **Important!** The asset pipeline is not invoking a controller to generate the
42
+ templates. If you are using existing view templates, you may have to edit
43
+ templates to remove some references to controller helpers.
47
44
 
48
45
  ### Helpers
49
46
 
50
- All the ActionView and route helpers are available in your template. If you use `form_for` and the related helpers, you should use the *new* object form, even if you are writing an *edit* form, for example
47
+ All the `ActionView` and route helpers are available in your template. If you use
48
+ `form_for` and the related helpers, you should use the *new* object style, even
49
+ if you are writing an *edit* template, for example
51
50
 
52
51
  = form_for :contact, url: "javascript_not_working", html: {:class => :edit_contact, :method => :put} do |f|
53
- %p
54
- = f.label :name, "Name"
55
- = f.text_field :name, class: 'text required', autofocus: true, value: '<%= name %>'.html_safe
52
+ = f.label :name, "Name"
53
+ = f.text_field :name, class: 'text required', autofocus: true, value: '{{name}}'
56
54
 
57
55
  # TODO
58
56
 
@@ -70,6 +68,5 @@ Once you've made your great commits:
70
68
 
71
69
  # Authors
72
70
 
73
- Les Hill : @leshill
74
-
71
+ Les Hill : @leshill
75
72
  Wes Gibbs : @wgibbs
@@ -10,11 +10,32 @@ module HamlAssets
10
10
  module ViewContext
11
11
  attr_accessor :output_buffer
12
12
 
13
+ def output_buffer_with_haml
14
+ return haml_buffer.buffer if is_haml?
15
+ output_buffer_without_haml
16
+ end
17
+
18
+ def set_output_buffer_with_haml(new)
19
+ if is_haml?
20
+ new = String.new(new) if Haml::Util.rails_xss_safe? &&
21
+ new.is_a?(Haml::Util.rails_safe_buffer_class)
22
+ haml_buffer.buffer = new
23
+ else
24
+ set_output_buffer_without_haml new
25
+ end
26
+ end
27
+
13
28
  def self.included(klass)
14
29
  klass.instance_eval do
15
30
  include Rails.application.routes.url_helpers
16
31
  include Rails.application.routes.mounted_helpers
17
32
  include ActionView::Helpers
33
+
34
+ alias_method :output_buffer_without_haml, :output_buffer
35
+ alias_method :output_buffer, :output_buffer_with_haml
36
+
37
+ alias_method :set_output_buffer_without_haml, :output_buffer=
38
+ alias_method :output_buffer=, :set_output_buffer_with_haml
18
39
  end
19
40
  end
20
41
 
@@ -1,3 +1,3 @@
1
1
  module HamlAssets
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-26 00:00:00.000000000Z
13
+ date: 2012-03-16 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: haml
17
- requirement: &70206153651580 !ruby/object:Gem::Requirement
17
+ requirement: &70119385661380 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70206153651580
25
+ version_requirements: *70119385661380
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: tilt
28
- requirement: &70206153650940 !ruby/object:Gem::Requirement
28
+ requirement: &70119385660240 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70206153650940
36
+ version_requirements: *70119385660240
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rails
39
- requirement: &70206153650100 !ruby/object:Gem::Requirement
39
+ requirement: &70119385659620 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 3.1.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70206153650100
47
+ version_requirements: *70119385659620
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &70206153649680 !ruby/object:Gem::Requirement
50
+ requirement: &70119385659040 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70206153649680
58
+ version_requirements: *70119385659040
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec-rails
61
- requirement: &70206153649100 !ruby/object:Gem::Requirement
61
+ requirement: &70119385658500 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70206153649100
69
+ version_requirements: *70119385658500
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: ejs
72
- requirement: &70206153648640 !ruby/object:Gem::Requirement
72
+ requirement: &70119385657720 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70206153648640
80
+ version_requirements: *70119385657720
81
81
  description: Use Haml with Rails helpers in the asset pipeline
82
82
  email:
83
83
  - les@infbio.com
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project: haml_assets
138
- rubygems_version: 1.8.10
138
+ rubygems_version: 1.8.17
139
139
  signing_key:
140
140
  specification_version: 3
141
141
  summary: Use Haml with Rails helpers in the asset pipeline