hogan_assets 1.3.4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 1.4.0 (2013-1-02)
2
+
3
+ * **slimstache** support, use `HoganAssets::Config.slim_options` to set options for `slim` - @sars
4
+ * Silence tilt require warning
5
+
1
6
  ## 1.3.4 (2012-11-09)
2
7
 
3
8
  * Use `HoganAssets::Config.haml_options` to set options for `haml` - @lautis
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hogan_assets (1.3.4)
4
+ hogan_assets (1.4.0)
5
5
  execjs (>= 1.2.9)
6
6
  sprockets (>= 2.0.3)
7
7
  tilt (>= 1.3.3)
@@ -15,11 +15,15 @@ GEM
15
15
  hike (1.2.1)
16
16
  multi_json (1.3.5)
17
17
  rack (1.4.1)
18
+ slim (1.3.4)
19
+ temple (~> 0.5.5)
20
+ tilt (~> 1.3.3)
18
21
  sprockets (2.4.3)
19
22
  hike (~> 1.2)
20
23
  multi_json (~> 1.0)
21
24
  rack (~> 1.0)
22
25
  tilt (~> 1.1, != 1.3.0)
26
+ temple (0.5.5)
23
27
  tilt (1.3.3)
24
28
 
25
29
  PLATFORMS
@@ -28,3 +32,4 @@ PLATFORMS
28
32
  DEPENDENCIES
29
33
  haml
30
34
  hogan_assets!
35
+ slim
data/README.md CHANGED
@@ -63,6 +63,10 @@ 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
+ ## Slimstache!
67
+
68
+ _slimstache_ is the also popular combination of `slim` and `mustache`. Works just like hamstache. Set the options via `slim_options`.
69
+
66
70
  ## Configuration
67
71
 
68
72
  ### Lambda Support
@@ -128,6 +132,7 @@ I made this because I <3 **mustache** and want to use it in Rails. Follow me on
128
132
  * @lautis (Ville Lautanala) : hamstache fix
129
133
  * @adamstrickland (Adam Strickland) : Custom template namespace
130
134
  * @lautis (Ville Lautanala) : haml_options configuration
135
+ * @sars (Rodion) : slimstache support
131
136
 
132
137
  ## Contributing
133
138
 
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
  gem.add_runtime_dependency "sprockets", ">= 2.0.3"
21
21
 
22
22
  gem.add_development_dependency "haml"
23
+ gem.add_development_dependency "slim"
23
24
  end
@@ -8,14 +8,15 @@ module HoganAssets
8
8
  # HoganAssets::Config.configure do |config|
9
9
  # config.lambda_support = false
10
10
  # config.path_prefix = 'templates'
11
- # config.template_extensions = ['mustache', 'hamstache']
11
+ # config.template_extensions = ['mustache', 'hamstache', 'slimstache']
12
12
  # config.haml_options[:ugly] = true
13
+ # config.slim_options[:pretty] = false
13
14
  # end
14
15
  #
15
16
  module Config
16
17
  extend self
17
18
 
18
- attr_writer :lambda_support, :path_prefix, :template_extensions, :template_namespace, :haml_options
19
+ attr_writer :lambda_support, :path_prefix, :template_extensions, :template_namespace, :haml_options, :slim_options
19
20
 
20
21
  def configure
21
22
  yield self
@@ -25,6 +26,10 @@ module HoganAssets
25
26
  defined? ::Haml::Engine
26
27
  end
27
28
 
29
+ def slim_available?
30
+ defined? ::Slim::Engine
31
+ end
32
+
28
33
  def lambda_support?
29
34
  @lambda_support
30
35
  end
@@ -38,15 +43,15 @@ module HoganAssets
38
43
  end
39
44
 
40
45
  def template_extensions
41
- @template_extensions ||= if haml_available?
42
- ['mustache', 'hamstache']
43
- else
44
- ['mustache']
45
- end
46
+ @template_extensions ||= "mustache#{' hamstache' if haml_available?}#{' slimstache' if slim_available?}".split
46
47
  end
47
48
 
48
49
  def haml_options
49
50
  @haml_options ||= {}
50
51
  end
52
+
53
+ def slim_options
54
+ @slim_options ||= {}
55
+ end
51
56
  end
52
57
  end
@@ -5,9 +5,8 @@ module HoganAssets
5
5
  self.default_mime_type = 'application/javascript'
6
6
 
7
7
  def initialize_engine
8
- require_template_library 'haml'
9
- rescue LoadError
10
- # haml not available
8
+ load_haml
9
+ load_slim
11
10
  end
12
11
 
13
12
  def evaluate(scope, locals, &block)
@@ -17,6 +16,9 @@ module HoganAssets
17
16
  text = if template_path.is_hamstache?
18
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?
19
18
  Haml::Engine.new(data, HoganAssets::Config.haml_options.merge(@options)).render
19
+ elsif template_path.is_slimstache?
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
20
22
  else
21
23
  data
22
24
  end
@@ -34,6 +36,18 @@ module HoganAssets
34
36
 
35
37
  protected
36
38
 
39
+ def load_haml
40
+ require 'haml'
41
+ rescue LoadError
42
+ # haml not available
43
+ end
44
+
45
+ def load_slim
46
+ require 'slim'
47
+ rescue LoadError
48
+ # slim not available
49
+ end
50
+
37
51
  def prepare; end
38
52
 
39
53
  class TemplatePath
@@ -48,6 +62,10 @@ module HoganAssets
48
62
  full_path.to_s.end_with? '.hamstache'
49
63
  end
50
64
 
65
+ def is_slimstache?
66
+ full_path.to_s.end_with? '.slimstache'
67
+ end
68
+
51
69
  def name
52
70
  @name ||= relative_path.dump
53
71
  end
@@ -1,3 +1,3 @@
1
1
  module HoganAssets
2
- VERSION = "1.3.4"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -97,7 +97,16 @@ module HoganAssets
97
97
  end
98
98
  scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.hamstache'
99
99
  template = HoganAssets::Tilt.new(scope.s_path) { "%p\n This is {{mustache}}" }
100
- assert_match /\"This is "/, template.render(scope, {})
100
+ assert_match /<p>/, template.render(scope, {})
101
+ end
102
+
103
+ def test_slim_options
104
+ HoganAssets::Config.configure do |config|
105
+ config.slim_options[:pretty] = false
106
+ end
107
+ scope = make_scope '/myapp/app/assets/javascripts', 'path/to/template.slimstache'
108
+ template = HoganAssets::Tilt.new(scope.s_path) { "p This is {{mustache}}" }
109
+ assert_match /<p>/, template.render(scope, {})
101
110
  end
102
111
  end
103
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hogan_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,72 +9,88 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
18
  - - ! '>='
20
19
  - !ruby/object:Gem::Version
21
20
  version: 1.2.9
22
- type: :runtime
21
+ none: false
23
22
  prerelease: false
23
+ type: :runtime
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: 1.2.9
29
+ none: false
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: tilt
32
32
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
33
  requirements:
35
34
  - - ! '>='
36
35
  - !ruby/object:Gem::Version
37
36
  version: 1.3.3
38
- type: :runtime
37
+ none: false
39
38
  prerelease: false
39
+ type: :runtime
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: 1.3.3
45
+ none: false
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: sprockets
48
48
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
49
  requirements:
51
50
  - - ! '>='
52
51
  - !ruby/object:Gem::Version
53
52
  version: 2.0.3
54
- type: :runtime
53
+ none: false
55
54
  prerelease: false
55
+ type: :runtime
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
57
  requirements:
59
58
  - - ! '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: 2.0.3
61
+ none: false
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: haml
64
64
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
65
  requirements:
67
66
  - - ! '>='
68
67
  - !ruby/object:Gem::Version
69
68
  version: '0'
70
- type: :development
69
+ none: false
71
70
  prerelease: false
71
+ type: :development
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ none: false
78
+ - !ruby/object:Gem::Dependency
79
+ name: slim
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
73
85
  none: false
86
+ prerelease: false
87
+ type: :development
88
+ version_requirements: !ruby/object:Gem::Requirement
74
89
  requirements:
75
90
  - - ! '>='
76
91
  - !ruby/object:Gem::Version
77
92
  version: '0'
93
+ none: false
78
94
  description: Use compiled hogan.js (mustache) JavaScript templates with sprockets
79
95
  and the Rails asset pipeline.
80
96
  email:
@@ -108,17 +124,17 @@ rdoc_options: []
108
124
  require_paths:
109
125
  - lib
110
126
  required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
127
  requirements:
113
128
  - - ! '>='
114
129
  - !ruby/object:Gem::Version
115
130
  version: '0'
116
- required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  none: false
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
133
  requirements:
119
134
  - - ! '>='
120
135
  - !ruby/object:Gem::Version
121
136
  version: '0'
137
+ none: false
122
138
  requirements: []
123
139
  rubyforge_project:
124
140
  rubygems_version: 1.8.24