stache 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWI2NDQ1YWVhNGRmYjJkYzQ1MTc3NWZjYjM4YTBlZmZiNGFiNGE0YQ==
5
+ data.tar.gz: !binary |-
6
+ MmU3MThiN2I1MzY4Nzc0NjkzMDBmODZmZmFmYjAxMmVjMzM1MDgyOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjQ0OThjOTI0ZGI3N2RhM2Y0YTJhOTEyOWRlMTY1MmY4N2MzNTcyOWE3YTU5
10
+ NzRmZmY1NzZkOGFkNDY2ZGY2YjU0YWQ2NGQ4ODJkMWU2NDAwZTc2YzVkYzRm
11
+ OTY1M2Y4YmI4MzU2MzZjMzg0MmMwNTk3ZTAzMGE3ODQ3OWEzZWQ=
12
+ data.tar.gz: !binary |-
13
+ NDdlYzQ1MzE5OWRlMTkwNGM2OGI3OGEzZTgwNTdjNzkxOTIyOWJhYzc4Y2Ew
14
+ ZTllMzIzY2FjY2M0NzEzOTcyYjQ0MjVhYTdiN2Q4YzkzMjYzM2Y2OGZlNjA4
15
+ ZDIyMzE0ZTFhNjMzYWI2YzU2YjFmZTVjOGQ2OGYzOWI2ZWVkYTc=
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ stache_gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p392
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in stache.gemspec
4
4
  gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Matt Wilson / Agora Games, LLC
1
+ Copyright (c) 2011-2013 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
@@ -138,4 +138,4 @@ Thanks a ton to all of the contributors as well. This would never have grown bey
138
138
 
139
139
  ## Copyright
140
140
 
141
- Copyright (c) 2011 Matt Wilson / Agora Games. See LICENSE for details.
141
+ Copyright (c) 2011-2013 Matt Wilson / Agora Games. See LICENSE for details.
@@ -16,21 +16,30 @@ module Stache
16
16
  # get a custom Mustache, or the default Stache::Mustache::View
17
17
  mustache_class = mustache_class_from_template(template)
18
18
 
19
+ # If the class is in the same directory as the template, the source of the template can be the
20
+ # source of the class, and so we need to read the template source from the file system.
21
+ # Matching against `module` may seem a bit hackish, but at worst it provides false positives
22
+ # only for templates containing the word `module`, and reads the template again from the file
23
+ # system.
24
+
25
+ template_is_class = template.source.match(/module/) ? true : false
26
+
19
27
  # Return a string that will be eval'd in the context of the ActionView, ugly, but it works.
20
28
  <<-MUSTACHE
21
29
  mustache = ::#{mustache_class}.new
22
30
  mustache.view = self
23
31
 
24
- # If we are rendering an abstract Stache::View class, don't render any template.
25
- if #{mustache_class} == Stache::Mustache::View
26
- template_source = '#{template.source.gsub(/'/, "\\\\'")}'
32
+ if #{template_is_class}
33
+ template_name = "#{template.virtual_path.to_s}"
34
+ file = Dir.glob(File.join(::Stache.template_base_path, template_name + "\.*" + mustache.template_extension)).first
35
+ template_source = File.read(file)
27
36
  else
28
- template_name = "#{template.virtual_path.to_s}.#{template.formats.first.to_s}."+mustache.template_extension
29
- template_source = File.read(File.join(::Stache.template_base_path, template_name))
37
+ template_source = '#{template.source.gsub(/'/, "\\\\'")}'
30
38
  end
31
39
 
32
40
  mustache.template = template_source
33
41
  mustache.virtual_path = '#{template.virtual_path.to_s}'
42
+ mustache[:yield] = content_for(:layout)
34
43
  mustache.context.update(local_assigns)
35
44
  variables = controller.instance_variable_names
36
45
  variables -= %w[@template]
@@ -1,3 +1,3 @@
1
1
  module Stache
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -23,7 +23,7 @@ describe HandlebarsController do
23
23
  assert_response 200
24
24
 
25
25
  response.should render_template 'with_wrapper'
26
- response.body.should =~ /Yes/
26
+ response.body.should =~ /answer: Yes/
27
27
  ensure
28
28
  Stache.wrapper_module_name = nil
29
29
  end
@@ -59,4 +59,26 @@ describe StacheController do
59
59
  response.should render_template 'helper' # view
60
60
  response.body.should == "/stache\n"
61
61
  end
62
+
63
+ it "does not require the format in the extension with view class" do
64
+ get :no_format_in_extension
65
+ assert_response 200
66
+
67
+ response.should render_template 'no_format_in_extension'
68
+ response.body.should == "No format"
69
+ end
70
+
71
+ it "does not require the format in the extension with view class and wrapper module" do
72
+ begin
73
+ Stache.wrapper_module_name = "Wrapper"
74
+
75
+ get :no_format_in_extension_with_wrapper
76
+ assert_response 200
77
+
78
+ response.should render_template 'no_format_in_extension_with_wrapper'
79
+ response.body.should == "No format"
80
+ ensure
81
+ Stache.wrapper_module_name = nil
82
+ end
83
+ end
62
84
  end
@@ -26,4 +26,12 @@ class StacheController < ApplicationController
26
26
  Stache::ViewContext.current = self.view_context
27
27
  end
28
28
 
29
+ def no_format_in_extension
30
+
31
+ end
32
+
33
+ def no_format_in_extension_with_wrapper
34
+
35
+ end
36
+
29
37
  end
@@ -1,3 +1,3 @@
1
1
  Am I using a wrapper module?
2
2
 
3
- {{answer}}
3
+ {{answer 'Yes'}}
@@ -0,0 +1,7 @@
1
+ module Stache
2
+ class NoFormatInExtension < Stache::Mustache::View
3
+ def format
4
+ "format"
5
+ end
6
+ end
7
+ end
@@ -11,6 +11,10 @@ Dummy::Application.routes.draw do
11
11
 
12
12
  get 'stache/with_wrapper', :to => 'stache#with_wrapper'
13
13
 
14
+ get 'stache/no_format_in_extension', :to => 'stache#no_format_in_extension'
15
+
16
+ get 'stache/no_format_in_extension_with_wrapper', :to => 'stache#no_format_in_extension_with_wrapper'
17
+
14
18
  get 'handlebars', :to => 'handlebars#index', :as => 'handlebars'
15
19
 
16
20
  get 'handlebars/with_partials', :to => 'handlebars#with_partials'
@@ -1,8 +1,8 @@
1
1
  module Wrapper
2
2
  module Handlebars
3
3
  class WithWrapper < ::Stache::Handlebars::View
4
- def answer
5
- "Yes"
4
+ def answer correct_answer
5
+ "answer: #{correct_answer}"
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,9 @@
1
+ module Wrapper
2
+ module Stache
3
+ class NoFormatInExtensionWithWrapper < ::Stache::Mustache::View
4
+ def format
5
+ "format"
6
+ end
7
+ end
8
+ end
9
+ end
data/stache.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.require_paths = ['lib']
26
26
 
27
27
  s.add_development_dependency 'mustache'
28
- s.add_development_dependency 'handlebars'
28
+ s.add_development_dependency 'handlebars', '~>0.4.0'
29
29
  s.add_development_dependency 'rails', '~>3.2.0'
30
30
  s.add_development_dependency 'rspec'
31
31
  s.add_development_dependency 'rspec-rails'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Wilson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
11
+ date: 2013-05-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mustache
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: handlebars
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: 0.4.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: 0.4.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec-rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: bundler
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rake
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -134,7 +119,8 @@ files:
134
119
  - .document
135
120
  - .gitignore
136
121
  - .rspec
137
- - .rvmrc
122
+ - .ruby-gemset
123
+ - .ruby-version
138
124
  - .travis.yml
139
125
  - CHANGELOG.md
140
126
  - Gemfile
@@ -177,6 +163,9 @@ files:
177
163
  - spec/dummy/app/views/stache/index.html.mustache
178
164
  - spec/dummy/app/views/stache/index.rb
179
165
  - spec/dummy/app/views/stache/layout.html.mustache
166
+ - spec/dummy/app/views/stache/no_format_in_extension.mustache
167
+ - spec/dummy/app/views/stache/no_format_in_extension.rb
168
+ - spec/dummy/app/views/stache/no_format_in_extension_with_wrapper.mustache
180
169
  - spec/dummy/app/views/stache/with_asset_helpers.html.mustache
181
170
  - spec/dummy/app/views/stache/with_layout.html.mustache
182
171
  - spec/dummy/app/views/stache/with_layout.rb
@@ -201,6 +190,7 @@ files:
201
190
  - spec/dummy/config/routes.rb
202
191
  - spec/dummy/lib/with_asset_helpers.rb
203
192
  - spec/dummy/lib/wrapper/handlebars/with_wrapper.rb
193
+ - spec/dummy/lib/wrapper/stache/no_format_in_extension_with_wrapper.rb
204
194
  - spec/dummy/lib/wrapper/stache/with_wrapper.rb
205
195
  - spec/dummy/public/404.html
206
196
  - spec/dummy/public/422.html
@@ -228,25 +218,24 @@ files:
228
218
  - stache.gemspec
229
219
  homepage: http://github.com/agoragames/stache
230
220
  licenses: []
221
+ metadata: {}
231
222
  post_install_message:
232
223
  rdoc_options: []
233
224
  require_paths:
234
225
  - lib
235
226
  required_ruby_version: !ruby/object:Gem::Requirement
236
- none: false
237
227
  requirements:
238
228
  - - ! '>='
239
229
  - !ruby/object:Gem::Version
240
230
  version: '0'
241
231
  required_rubygems_version: !ruby/object:Gem::Requirement
242
- none: false
243
232
  requirements:
244
233
  - - ! '>='
245
234
  - !ruby/object:Gem::Version
246
235
  version: 1.3.7
247
236
  requirements: []
248
237
  rubyforge_project:
249
- rubygems_version: 1.8.24
238
+ rubygems_version: 2.0.3
250
239
  signing_key:
251
240
  specification_version: 3
252
241
  summary: Configurable Mustache Handler and Helpers for Rails
@@ -272,6 +261,9 @@ test_files:
272
261
  - spec/dummy/app/views/stache/index.html.mustache
273
262
  - spec/dummy/app/views/stache/index.rb
274
263
  - spec/dummy/app/views/stache/layout.html.mustache
264
+ - spec/dummy/app/views/stache/no_format_in_extension.mustache
265
+ - spec/dummy/app/views/stache/no_format_in_extension.rb
266
+ - spec/dummy/app/views/stache/no_format_in_extension_with_wrapper.mustache
275
267
  - spec/dummy/app/views/stache/with_asset_helpers.html.mustache
276
268
  - spec/dummy/app/views/stache/with_layout.html.mustache
277
269
  - spec/dummy/app/views/stache/with_layout.rb
@@ -296,6 +288,7 @@ test_files:
296
288
  - spec/dummy/config/routes.rb
297
289
  - spec/dummy/lib/with_asset_helpers.rb
298
290
  - spec/dummy/lib/wrapper/handlebars/with_wrapper.rb
291
+ - spec/dummy/lib/wrapper/stache/no_format_in_extension_with_wrapper.rb
299
292
  - spec/dummy/lib/wrapper/stache/with_wrapper.rb
300
293
  - spec/dummy/public/404.html
301
294
  - spec/dummy/public/422.html
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.3@stache_gem