stache 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzZkZjUyYzllZWRhODJkYzc4YTViMGFhYzlkOTgyMTU2MmVkZjgwOQ==
5
- data.tar.gz: !binary |-
6
- M2M5MGM0ZDU5Zjk3YWVmMWFiZWI1ZDM3MTUxMzMzMTY1NDM3ODZiOA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YzJmYjgyYmQ2MzBkOTZiOWIxNzI4NmRkZWUxY2Q0OTNjNzk4MWIwMDQ5Mzg2
10
- ZTQ4Y2IxMjkyYjRmNWFkODhkMjU0Yzk2ZDE1MDAyNTQwM2Q3YTcxNWVmZmE4
11
- MzkwMmI2MGUwNjUzMDlhMDc2ZTc1YzhmYjkzYTEzZGI2Y2Y1ZmE=
12
- data.tar.gz: !binary |-
13
- MDEyNTAyMDg4OTcwYmFjMWNmNjUzMWVhODdkMzQ1NWE2NTNlZDM0YzUwMjll
14
- NDZhZTBiNzc2MzNlNWE0YTAwMmUwNjk0MzhhMTY5YWNmYTdkZTNjYzg3YjFl
15
- NjE0OTkxZjgwNTY3OGJiNjM5ZjAwYTQ5OTU2ZTJjZTdkOGU1MzA=
2
+ SHA1:
3
+ metadata.gz: 4c4d478dbffc3306efd783fe17d868a8879c0b24
4
+ data.tar.gz: ddba634b4929cc0ac1c83ef8f888b13cee625f10
5
+ SHA512:
6
+ metadata.gz: f1b49b3ddf56014e1bae27183c5b7b393415d4d27e39884a2701bf505f88b1134fdbd31cd9ed0fe1aecb6920e1ccc9cb327a898082d88d904f1afef33daa0089
7
+ data.tar.gz: 0747cd7f832dfdaaca2adeeae2fb3316cf52f9bc582a375139523ea2ea2e64982bba6153a340b99011d7fda39a1285a5957ec65940bb75d50e7b8ee5cbdfb745
@@ -1 +1 @@
1
- ruby-1.9.3-p392
1
+ ruby-2.0.0
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
- - 1.9.3
3
+ - 1.9.3
4
+ - 2.0.0
@@ -1,12 +1,20 @@
1
- # 1.0.1
1
+ # CHANGELOG
2
+
3
+ ## 1.0.3 (2014-01-14)
4
+
5
+ * Access RSpec-assigned instance variables in view classes (Thanks [@kianw](https://github.com/kianw))
6
+ * Rails4 compatibility at long last!
7
+ * Ruby2 required for development, as it is preferred by rails4.
8
+
9
+ ## 1.0.2 (2013-05-10)
2
10
 
3
11
  * Change autoload paths to an array of Strings instead of Pathnames, for greater compatibility.
4
12
 
5
- # 1.0.1
13
+ ## 1.0.1 (2013-05-07)
6
14
 
7
15
  * Fix a regression in mustache layout handling.
8
16
 
9
- # 1.0.0
17
+ ## 1.0.0 (2012-11-29)
10
18
 
11
19
  * Overhauled Mustache template engine. If you wish to have Mustache drive your entire template stack, you can invert control to it.
12
20
  * Fixed a bunch of problems with Handlebars access to the view namespace for helpers, etc.
@@ -16,11 +24,11 @@ Backwards compatibility should be fine; any regressions are bugs and should be r
16
24
 
17
25
  Huge thanks to all contributors!
18
26
 
19
- # 0.9.1
27
+ ## 0.9.1
20
28
 
21
29
  * soften our hardcore stance on missing properties.
22
30
 
23
- # 0.9.0
31
+ ## 0.9.0
24
32
 
25
33
  /!\ /!\ Breaking Changes.
26
34
 
@@ -30,14 +38,14 @@ Huge thanks to all contributors!
30
38
 
31
39
  There's some code duplication that should be crushed out before 1.0.
32
40
 
33
- # 0.2.2
41
+ ## 0.2.2
34
42
 
35
43
  * Saner, consistent handling of template extensions: partials and full templates both use configured value at `Stache.template_extension`. Thanks @ajacksified!
36
44
 
37
- # 0.2.1
45
+ ## 0.2.1
38
46
 
39
47
  * Addresses #9: fix 'incompatible character encodings' error
40
48
 
41
- # 0.2.0
49
+ ## 0.2.0
42
50
 
43
51
  * Patch to properly reraise NameError/LoadError that occurs upon loading a Stache::View
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2013 Matt Wilson / Agora Games, LLC
1
+ Copyright (c) 2011-2014 Matt Wilson / Agora Games, LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -92,6 +92,54 @@ I'm a handlebars template. Look at me call a helper: {{{image_path my_image}}}
92
92
 
93
93
  You can subclass `Stache::Handlebars::View` in the same way as mustache above, but there isn't as much point in doing so.
94
94
 
95
+ ## View Specs
96
+
97
+ Yes, you can write view specs using RSpec for your Stache templates! You can use RSpec's `assign` method to
98
+ assign values to view instance variables, which will then be be available to the Stache view, either as
99
+ instance variables, or via an accessor. Any instance variables defined in the RSpec example will also be
100
+ similarly available, so
101
+
102
+ ```ruby
103
+ it "should display my instance variable" do
104
+ assign(:resource, "Foo")
105
+ render
106
+ ...
107
+ end
108
+ ```
109
+ and
110
+
111
+ ```ruby
112
+ it "should display my instance variable" do
113
+ @resource = "Foo"
114
+ render
115
+ ...
116
+ end
117
+ ```
118
+ both make `@resource` available to the Stache view.
119
+
120
+ ## Non-Mustache Partials
121
+
122
+ Yes, you can include non-Mustache partials (and templates) in your Stache templates. However, the
123
+ `{{>partial_name_here}}` syntax in the template won't find a non-Mustache template. You can define
124
+ a method in the view and reference it in the template. The view method should use `@view.render` to
125
+ render the non-Mustache partial and return its content. Example:
126
+
127
+ Mustache template:
128
+
129
+ ```
130
+ {{{my_haml_sidebar}}}
131
+ ```
132
+
133
+ View:
134
+
135
+ ```ruby
136
+ class MyPage < ::Stache::Mustache::View
137
+ def my_haml_sidebar
138
+ @view.render partial: 'somewhere/some_haml_partial_name'
139
+ end
140
+ end
141
+ ```
142
+
95
143
  ## Of Note
96
144
 
97
145
  This is code that was ripped out of a research project. It probably has some rough edges.
@@ -139,4 +187,4 @@ Thanks a ton to all of the contributors as well. This would never have grown bey
139
187
 
140
188
  ## Copyright
141
189
 
142
- Copyright (c) 2011-2013 Matt Wilson / Agora Games. See LICENSE for details.
190
+ Copyright (c) 2011-2014 Matt Wilson / Agora Games. See LICENSE for details.
@@ -36,7 +36,7 @@ module Stache
36
36
 
37
37
  template = handlebars.compile('#{template.source.gsub(/'/, "\\\\'")}');
38
38
  vars = {}
39
- partial_renderer = @view_renderer.send(:_partial_renderer)
39
+ partial_renderer = PartialRenderer.new(lookup_context)
40
40
  vars.merge!(@_assigns)
41
41
  vars.merge!(partial_renderer.instance_variable_get('@locals') || {})
42
42
  options = partial_renderer.instance_variable_get('@options')
@@ -52,6 +52,11 @@ module Stache
52
52
  mustache.instance_variable_set(name, controller.instance_variable_get(name))
53
53
  end
54
54
 
55
+ # Add view instance variables also so RSpec view spec assigns will work
56
+ (instance_variable_names - variables).each do |name|
57
+ mustache.instance_variable_set(name, instance_variable_get(name))
58
+ end
59
+
55
60
  # Declaring an +attr_reader+ for each instance variable in the
56
61
  # Stache::Mustache::View subclass makes them available to your templates.
57
62
  mustache.class.class_eval do
@@ -1,3 +1,3 @@
1
1
  module Stache
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -41,7 +41,7 @@ describe HandlebarsController do
41
41
  get :with_helpers
42
42
  assert_response 200
43
43
 
44
- response.body.should =~ /Here's an image_path=\/assets\/image\.png/
44
+ response.body.should =~ /Here's an image_path=\/images\/image\.png/
45
45
  response.body.should =~ /Here's a capitalized string: Lowercase/
46
46
  end
47
47
 
@@ -41,7 +41,7 @@ describe StacheController do
41
41
  get :with_asset_helpers
42
42
  assert_response 200
43
43
 
44
- response.body.should =~ /Here's an image_path=\/assets\/image\.png/
44
+ response.body.should =~ /Here's an image_path=\/images\/image\.png/
45
45
  response.body.should =~ /link href="\/assets\/test\.css"/
46
46
  end
47
47
 
@@ -0,0 +1 @@
1
+ Hello, {{user}}!
@@ -0,0 +1,5 @@
1
+ module Stache
2
+ class Accessor < Stache::Mustache::View
3
+ attr_accessor :user
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ Hello, {{user}}!
@@ -0,0 +1,7 @@
1
+ module Stache
2
+ class Ivar < Stache::Mustache::View
3
+ def user
4
+ @user_name
5
+ end
6
+ end
7
+ end
@@ -6,8 +6,8 @@ Dummy::Application.configure do
6
6
  # since you don't have to restart the webserver when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
9
+ # eager load
10
+ config.eager_load = false
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
@@ -5,6 +5,9 @@ Dummy::Application.configure do
5
5
  # Code is not reloaded between requests
6
6
  config.cache_classes = true
7
7
 
8
+ # eager load
9
+ config.eager_load = true
10
+
8
11
  # Full error reports are disabled and caching is turned on
9
12
  config.consider_all_requests_local = false
10
13
  config.action_controller.perform_caching = true
@@ -7,8 +7,8 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
10
+ # eager load
11
+ config.eager_load = false
12
12
 
13
13
  # Show full error reports and disable caching
14
14
  config.consider_all_requests_local = true
@@ -13,7 +13,7 @@ describe Stache::Handlebars::Handler do
13
13
  Object.send(:remove_const, :HelloWorld)
14
14
  end
15
15
  it "is clever about folders and such" do
16
- @template.stub!(:virtual_path).and_return("profiles/index")
16
+ @template.stub(:virtual_path).and_return("profiles/index")
17
17
  module Profiles; class Index < Stache::Handlebars::View; end; end
18
18
  @handler.handlebars_class_from_template(@template).should == Profiles::Index
19
19
  Object.send(:remove_const, :Profiles)
@@ -22,7 +22,7 @@ describe Stache::Handlebars::Handler do
22
22
  @handler.handlebars_class_from_template(@template).should == Stache::Handlebars::View
23
23
  end
24
24
  it "reraises error if loaded handlebars_class raises a NameError" do
25
- @template.stub!(:virtual_path).and_return("profiles/index")
25
+ @template.stub(:virtual_path).and_return("profiles/index")
26
26
  module Profiles; end
27
27
  # Emulate autoload behavior so the error gets raised upon const_get
28
28
  Profiles.autoload :Index, File.join(File.dirname(__FILE__), "profile_autoload.rb")
@@ -46,7 +46,7 @@ describe Stache::Handlebars::Handler do
46
46
  Object.send(:remove_const, :Wrapper)
47
47
  end
48
48
  it "is clever about folders and such" do
49
- @template.stub!(:virtual_path).and_return("profiles/index")
49
+ @template.stub(:virtual_path).and_return("profiles/index")
50
50
  module Wrapper; module Profiles; class Index < ::Stache::Handlebars::View; end; end; end
51
51
  @handler.handlebars_class_from_template(@template).should == Wrapper::Profiles::Index
52
52
  Object.send(:remove_const, :Wrapper)
@@ -17,7 +17,7 @@ describe Stache::Mustache::Handler do
17
17
  Object.send(:remove_const, :HelloWorld)
18
18
  end
19
19
  it "is clever about folders and such" do
20
- @template.stub!(:virtual_path).and_return("profiles/index")
20
+ @template.stub(:virtual_path).and_return("profiles/index")
21
21
  module Profiles; class Index < Stache::Mustache::View; end; end
22
22
  @handler.mustache_class_from_template(@template).should == Profiles::Index
23
23
  Object.send(:remove_const, :Profiles)
@@ -26,7 +26,7 @@ describe Stache::Mustache::Handler do
26
26
  @handler.mustache_class_from_template(@template).should == Stache::Mustache::View
27
27
  end
28
28
  it "reraises error if loaded mustache_class raises a NameError" do
29
- @template.stub!(:virtual_path).and_return("profiles/index")
29
+ @template.stub(:virtual_path).and_return("profiles/index")
30
30
  module Profiles; end
31
31
  # Emulate autoload behavior so the error gets raised upon const_get
32
32
  Profiles.autoload :Index, File.join(File.dirname(__FILE__), "profile_autoload.rb")
@@ -50,7 +50,7 @@ describe Stache::Mustache::Handler do
50
50
  Object.send(:remove_const, :Wrapper)
51
51
  end
52
52
  it "is clever about folders and such" do
53
- @template.stub!(:virtual_path).and_return("profiles/index")
53
+ @template.stub(:virtual_path).and_return("profiles/index")
54
54
  module Wrapper; module Profiles; class Index < ::Stache::Mustache::View; end; end; end
55
55
  @handler.mustache_class_from_template(@template).should == Wrapper::Profiles::Index
56
56
  Object.send(:remove_const, :Wrapper)
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'stache/accessor' do
4
+ it "should pass an instance variable through via an accessor" do
5
+ assign(:user, "Magnus")
6
+ render
7
+ rendered.should include "Magnus"
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'stache/ivar' do
4
+ it "should access an instance variable defined with RSpec #assign in a view method" do
5
+ assign(:user_name, "Thomas")
6
+ render
7
+ rendered.should include "Thomas"
8
+ end
9
+
10
+ it "should access an instance variable defined directly in RSpec in a view method" do
11
+ @user_name = "Stefan"
12
+ render
13
+ rendered.should include "Stefan"
14
+ end
15
+ end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = 'http://github.com/agoragames/stache'
11
11
  s.summary = %Q{Configurable Mustache Handler and Helpers for Rails}
12
12
  s.description = %Q{A rails 3.x compatible template handler, configurable.}
13
+ s.license = 'MIT'
13
14
  s.extra_rdoc_files = [
14
15
  'LICENSE',
15
16
  'README.md',
@@ -26,7 +27,7 @@ Gem::Specification.new do |s|
26
27
 
27
28
  s.add_development_dependency 'mustache'
28
29
  s.add_development_dependency 'handlebars', '~>0.4.0'
29
- s.add_development_dependency 'rails', '~>3.2.0'
30
+ s.add_development_dependency 'rails', '~>4.0.0'
30
31
  s.add_development_dependency 'rspec'
31
32
  s.add_development_dependency 'rspec-rails'
32
33
  s.add_development_dependency 'bundler'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-10 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
@@ -44,68 +44,68 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 3.2.0
47
+ version: 4.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 3.2.0
54
+ version: 4.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: A rails 3.x compatible template handler, configurable.
@@ -158,10 +158,14 @@ files:
158
158
  - spec/dummy/app/views/handlebars/with_wrapper.html.hbs
159
159
  - spec/dummy/app/views/layouts/application.html.erb
160
160
  - spec/dummy/app/views/stache/_eaten_by_a.html.mustache
161
+ - spec/dummy/app/views/stache/accessor.html.mustache
162
+ - spec/dummy/app/views/stache/accessor.rb
161
163
  - spec/dummy/app/views/stache/helper.html.mustache
162
164
  - spec/dummy/app/views/stache/helper.rb
163
165
  - spec/dummy/app/views/stache/index.html.mustache
164
166
  - spec/dummy/app/views/stache/index.rb
167
+ - spec/dummy/app/views/stache/ivar.html.mustache
168
+ - spec/dummy/app/views/stache/ivar.rb
165
169
  - spec/dummy/app/views/stache/layout.html.mustache
166
170
  - spec/dummy/app/views/stache/no_format_in_extension.mustache
167
171
  - spec/dummy/app/views/stache/no_format_in_extension.rb
@@ -215,9 +219,12 @@ files:
215
219
  - spec/stache/mustache/view_spec.rb
216
220
  - spec/stache/util_spec.rb
217
221
  - spec/stache_spec.rb
222
+ - spec/views/accessor_spec.rb
223
+ - spec/views/ivar_spec.rb
218
224
  - stache.gemspec
219
225
  homepage: http://github.com/agoragames/stache
220
- licenses: []
226
+ licenses:
227
+ - MIT
221
228
  metadata: {}
222
229
  post_install_message:
223
230
  rdoc_options: []
@@ -225,17 +232,17 @@ require_paths:
225
232
  - lib
226
233
  required_ruby_version: !ruby/object:Gem::Requirement
227
234
  requirements:
228
- - - ! '>='
235
+ - - '>='
229
236
  - !ruby/object:Gem::Version
230
237
  version: '0'
231
238
  required_rubygems_version: !ruby/object:Gem::Requirement
232
239
  requirements:
233
- - - ! '>='
240
+ - - '>='
234
241
  - !ruby/object:Gem::Version
235
242
  version: 1.3.7
236
243
  requirements: []
237
244
  rubyforge_project:
238
- rubygems_version: 2.0.3
245
+ rubygems_version: 2.2.0
239
246
  signing_key:
240
247
  specification_version: 3
241
248
  summary: Configurable Mustache Handler and Helpers for Rails
@@ -256,10 +263,14 @@ test_files:
256
263
  - spec/dummy/app/views/handlebars/with_wrapper.html.hbs
257
264
  - spec/dummy/app/views/layouts/application.html.erb
258
265
  - spec/dummy/app/views/stache/_eaten_by_a.html.mustache
266
+ - spec/dummy/app/views/stache/accessor.html.mustache
267
+ - spec/dummy/app/views/stache/accessor.rb
259
268
  - spec/dummy/app/views/stache/helper.html.mustache
260
269
  - spec/dummy/app/views/stache/helper.rb
261
270
  - spec/dummy/app/views/stache/index.html.mustache
262
271
  - spec/dummy/app/views/stache/index.rb
272
+ - spec/dummy/app/views/stache/ivar.html.mustache
273
+ - spec/dummy/app/views/stache/ivar.rb
263
274
  - spec/dummy/app/views/stache/layout.html.mustache
264
275
  - spec/dummy/app/views/stache/no_format_in_extension.mustache
265
276
  - spec/dummy/app/views/stache/no_format_in_extension.rb
@@ -313,3 +324,5 @@ test_files:
313
324
  - spec/stache/mustache/view_spec.rb
314
325
  - spec/stache/util_spec.rb
315
326
  - spec/stache_spec.rb
327
+ - spec/views/accessor_spec.rb
328
+ - spec/views/ivar_spec.rb