hogan_assets 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use @hogan_assets
1
+ rvm gemset use --create hogan_assets
@@ -1,3 +1,8 @@
1
+ ## 1.5.1 (2013-2-26)
2
+
3
+ * hamstache\_extensions and slimstache\_extensions options - @AlexRiedler
4
+ * pass scope and locals to `haml` and `slim` - @AlexRiedler
5
+
1
6
  ## 1.5.0 (2013-2-06)
2
7
 
3
8
  * YAML configuration support - @apai4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hogan_assets (1.5.0)
4
+ hogan_assets (1.5.1)
5
5
  execjs (>= 1.2.9)
6
6
  sprockets (>= 2.0.3)
7
7
  tilt (>= 1.3.3)
data/README.md CHANGED
@@ -63,9 +63,15 @@ Hamstache compilation can be configured using [Haml options](http://haml.info/do
63
63
  config.haml_options[:ugly] = true
64
64
  end
65
65
 
66
+ You can configure which recognized as _hamstache_. For example:
67
+
68
+ HoganAssets::Config.configure do |config|
69
+ config.hamstache_extensions = %w(hamstache hamlhbs)
70
+ end
71
+
66
72
  ## Slimstache!
67
73
 
68
- _slimstache_ is the also popular combination of `slim` and `mustache`. Works just like hamstache. Set the options via `slim_options`.
74
+ _slimstache_ is the also popular combination of `slim` and `mustache`. Works just like hamstache above.
69
75
 
70
76
  ## Configuration
71
77
 
@@ -137,6 +143,7 @@ I made this because I <3 **mustache** and want to use it in Rails. Follow me on
137
143
  * @lautis (Ville Lautanala) : haml_options configuration
138
144
  * @sars (Rodion) : slimstache support
139
145
  * @apai4 : YAML configuration
146
+ * @AlexRiedler (Alex Riedler) : hamstache/slimstache extensions and helper support
140
147
 
141
148
  ## Contributing
142
149
 
@@ -38,7 +38,8 @@ module HoganAssets
38
38
  module Config
39
39
  extend self
40
40
 
41
- attr_writer :env, :lambda_support, :path_prefix, :template_extensions, :template_namespace, :haml_options, :slim_options
41
+ attr_writer :env, :lambda_support, :path_prefix, :template_extensions, :template_namespace, :haml_options, :slim_options,
42
+ :slimstache_extensions, :hamstache_extensions
42
43
 
43
44
  def configure
44
45
  yield self
@@ -73,6 +74,8 @@ module HoganAssets
73
74
  @template_namespace = yml['template_namespace'] if yml.has_key? 'template_namespace'
74
75
  @haml_options = yml['haml_options'] if yml.has_key? 'haml_options'
75
76
  @slim_options = yml['slim_options'] if yml.has_key? 'slim_options'
77
+ @slimstache_extensions = yml['slimstache_extensions'] if yml.has_key? 'slimstache_extensions'
78
+ @hamstache_extensions = yml['hamstache_extensions'] if yml.has_key? 'hamstache_extensions'
76
79
  symbolize(@haml_options) if @haml_options
77
80
  symbolize(@slim_options) if @slim_options
78
81
  end
@@ -97,6 +100,14 @@ module HoganAssets
97
100
  @template_extensions ||= "mustache#{' hamstache' if haml_available?}#{' slimstache' if slim_available?}".split
98
101
  end
99
102
 
103
+ def hamstache_extensions
104
+ @hamstache_extensions ||= ['hamstache']
105
+ end
106
+
107
+ def slimstache_extensions
108
+ @slimstache_extensions ||= ['slimstache']
109
+ end
110
+
100
111
  def yml
101
112
  begin
102
113
  @yml ||= (YAML.load(IO.read yml_path)[env] rescue nil) || {}
@@ -15,10 +15,10 @@ module HoganAssets
15
15
 
16
16
  text = if template_path.is_hamstache?
17
17
  raise "Unable to compile #{template_path.full_path} because haml is not available. Did you add the haml gem?" unless HoganAssets::Config.haml_available?
18
- Haml::Engine.new(data, HoganAssets::Config.haml_options.merge(@options)).render
18
+ Haml::Engine.new(data, HoganAssets::Config.haml_options.merge(@options)).render(scope, locals)
19
19
  elsif template_path.is_slimstache?
20
20
  raise "Unable to compile #{template_path.full_path} because slim is not available. Did you add the slim gem?" unless HoganAssets::Config.slim_available?
21
- Slim::Template.new(HoganAssets::Config.slim_options.merge(@options)) { data }.render
21
+ Slim::Template.new(HoganAssets::Config.slim_options.merge(@options)) { data }.render(scope, locals)
22
22
  else
23
23
  data
24
24
  end
@@ -59,11 +59,13 @@ module HoganAssets
59
59
  end
60
60
 
61
61
  def is_hamstache?
62
- full_path.to_s.end_with? '.hamstache'
62
+ file_path = full_path.to_s
63
+ HoganAssets::Config.hamstache_extensions.any? { |ext| file_path.to_s.end_with? ext }
63
64
  end
64
65
 
65
66
  def is_slimstache?
66
- full_path.to_s.end_with? '.slimstache'
67
+ file_path = full_path.to_s
68
+ HoganAssets::Config.slimstache_extensions.any? { |ext| file_path.to_s.end_with? ext }
67
69
  end
68
70
 
69
71
  def name
@@ -1,3 +1,3 @@
1
1
  module HoganAssets
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -5,8 +5,7 @@ module HoganAssets
5
5
  include TestSupport
6
6
 
7
7
  def teardown
8
- HoganAssets::Config.lambda_support = false
9
- HoganAssets::Config.path_prefix = 'templates'
8
+ HoganAssets::Config.reset!
10
9
  end
11
10
 
12
11
  def test_mime_type
@@ -83,8 +82,9 @@ module HoganAssets
83
82
  def test_haml_options
84
83
  HoganAssets::Config.configure do |config|
85
84
  config.haml_options[:ugly] = true
85
+ config.hamstache_extensions = ['hamlhbs']
86
86
  end
87
- scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.hamstache'
87
+ scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.hamlhbs'
88
88
  template = HoganAssets::Tilt.new(scope.s_path) { "%p\n This is {{mustache}}" }
89
89
  assert_match /<p>/, template.render(scope, {})
90
90
  end
@@ -92,8 +92,9 @@ module HoganAssets
92
92
  def test_slim_options
93
93
  HoganAssets::Config.configure do |config|
94
94
  config.slim_options[:pretty] = false
95
+ config.slimstache_extensions = ['slimhbs']
95
96
  end
96
- scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.slimstache'
97
+ scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.slimhbs'
97
98
  template = HoganAssets::Tilt.new(scope.s_path) { "p This is {{mustache}}" }
98
99
  assert_match /<p>/, template.render(scope, {})
99
100
  end
@@ -2,6 +2,15 @@ require 'hogan_assets'
2
2
 
3
3
  require 'test/unit'
4
4
 
5
+ module HoganAssets::Config
6
+ def reset!
7
+ %w(env lambda_support path_prefix template_extensions template_namespace haml_options slim_options slimstache_extensions hamstache_extensions).each do |option|
8
+ send "#{option}=", nil
9
+ end
10
+
11
+
12
+ end
13
+ end
5
14
  module TestSupport
6
15
  # Try to act like sprockets.
7
16
  def make_scope(root, file)
metadata CHANGED
@@ -1,18 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hogan_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
5
4
  prerelease:
5
+ version: 1.5.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Les Hill
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.9
16
22
  requirement: !ruby/object:Gem::Requirement
17
23
  none: false
18
24
  requirements:
@@ -21,14 +27,14 @@ dependencies:
21
27
  version: 1.2.9
22
28
  type: :runtime
23
29
  prerelease: false
30
+ - !ruby/object:Gem::Dependency
31
+ name: tilt
24
32
  version_requirements: !ruby/object:Gem::Requirement
25
33
  none: false
26
34
  requirements:
27
35
  - - ! '>='
28
36
  - !ruby/object:Gem::Version
29
- version: 1.2.9
30
- - !ruby/object:Gem::Dependency
31
- name: tilt
37
+ version: 1.3.3
32
38
  requirement: !ruby/object:Gem::Requirement
33
39
  none: false
34
40
  requirements:
@@ -37,14 +43,14 @@ dependencies:
37
43
  version: 1.3.3
38
44
  type: :runtime
39
45
  prerelease: false
46
+ - !ruby/object:Gem::Dependency
47
+ name: sprockets
40
48
  version_requirements: !ruby/object:Gem::Requirement
41
49
  none: false
42
50
  requirements:
43
51
  - - ! '>='
44
52
  - !ruby/object:Gem::Version
45
- version: 1.3.3
46
- - !ruby/object:Gem::Dependency
47
- name: sprockets
53
+ version: 2.0.3
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  none: false
50
56
  requirements:
@@ -53,14 +59,14 @@ dependencies:
53
59
  version: 2.0.3
54
60
  type: :runtime
55
61
  prerelease: false
62
+ - !ruby/object:Gem::Dependency
63
+ name: debugger
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
65
  none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
- version: 2.0.3
62
- - !ruby/object:Gem::Dependency
63
- name: debugger
69
+ version: '0'
64
70
  requirement: !ruby/object:Gem::Requirement
65
71
  none: false
66
72
  requirements:
@@ -69,14 +75,14 @@ dependencies:
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
78
+ - !ruby/object:Gem::Dependency
79
+ name: haml
72
80
  version_requirements: !ruby/object:Gem::Requirement
73
81
  none: false
74
82
  requirements:
75
83
  - - ! '>='
76
84
  - !ruby/object:Gem::Version
77
85
  version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: haml
80
86
  requirement: !ruby/object:Gem::Requirement
81
87
  none: false
82
88
  requirements:
@@ -85,14 +91,14 @@ dependencies:
85
91
  version: '0'
86
92
  type: :development
87
93
  prerelease: false
94
+ - !ruby/object:Gem::Dependency
95
+ name: slim
88
96
  version_requirements: !ruby/object:Gem::Requirement
89
97
  none: false
90
98
  requirements:
91
99
  - - ! '>='
92
100
  - !ruby/object:Gem::Version
93
101
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: slim
96
102
  requirement: !ruby/object:Gem::Requirement
97
103
  none: false
98
104
  requirements:
@@ -101,12 +107,6 @@ dependencies:
101
107
  version: '0'
102
108
  type: :development
103
109
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
110
  description: Use compiled hogan.js (mustache) JavaScript templates with sprockets
111
111
  and the Rails asset pipeline.
112
112
  email:
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 1.8.23
158
+ rubygems_version: 1.8.25
159
159
  signing_key:
160
160
  specification_version: 3
161
161
  summary: Use compiled hogan.js (mustache) JavaScript templates with sprockets and