stache 1.1.1 → 1.2.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35a70dffe63e8b3339b268a7e7e8f392b7b23fcb
4
- data.tar.gz: e096b6bcf5d4aab498db1fb9032d9a34f07bf169
3
+ metadata.gz: 054db3b0e3f7b82ef3956bc71f14ac88ac0e3979
4
+ data.tar.gz: ffa24c3eeec2b9bb6c7fbb6ee67c7fa568d9686a
5
5
  SHA512:
6
- metadata.gz: ce5651630bf430ecef53aa54a69c4d6a8687fd8d7166e385bc1e52c4a3547ace23b998e0dd633a70295ac193897ce4f506ce9f18c2447b4144e1b5b56d70e739
7
- data.tar.gz: 1a262d6abdb6429f377aa95ef034d17b7d4f52e21aef22fb4651887d937bd61155ac4dda506d7f6c43dd5ca914ec7ced0908330df00b9a5f74f2d47c3ab91ca2
6
+ metadata.gz: 776a8039d52c35c500c4a317c68b1c00fc53c3ef08f073c90971a7790eed46ae221afe80e31ba0e7f7017919269477acb5caa5af920b59583181550586d67942
7
+ data.tar.gz: c6c2c9ce401bde12551d20fec963cd01398f688e7deb253becffc16f30dcc1b42c89657c0e1d28ed8621caaa013b7e62d2b80eb91fe7e009f72948ad4159a225
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0 (2017-02-03)
4
+
5
+ * Rails 5 functionality
6
+ * Adding controller generators
7
+ * Adding configuration options for `template_extension` and `template_base_class`
8
+
9
+ ## 1.1.1 (2015-03-19)
10
+
11
+ * Bugfixes from many new contributors and some expanded test coverage! Thanks very much to all!
12
+
13
+ Still waiting on handlebars.rb upstream to upgrade off of handlebars 1.3 (the current version is 3) to get handlebars on the same support level as mustache.
14
+
3
15
  ## 1.1.0 (2014-09-05)
4
16
 
5
17
  * Overhaul of Stache::Mustache rendering by [@MarkusHarmsen](https://github.com/MarkusHarmsen) brings caching, and with it, 200-300% rendering performance enhancements. Thanks!
@@ -0,0 +1,9 @@
1
+ module Stache
2
+ module Generators
3
+ module TemplatePath
4
+ def source_root
5
+ @_mustache_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'stache', generator_name, 'templates'))
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,40 @@
1
+ require 'generators/stache'
2
+ require 'rails/generators/named_base'
3
+
4
+ module Stache
5
+ module Generators
6
+ class ControllerGenerator < ::Rails::Generators::NamedBase
7
+ extend TemplatePath
8
+
9
+ argument :actions, :type => :array, :default => [], :banner => "action action"
10
+
11
+ def create_view_files
12
+ model_path = File.join(class_path, file_name)
13
+
14
+ base_mustache_view_path = File.join("app/views", model_path)
15
+ empty_directory base_mustache_view_path
16
+
17
+ base_mustache_template_path = File.join("app/templates", model_path)
18
+ empty_directory base_mustache_template_path
19
+
20
+ @base_class = Stache.template_base_class
21
+
22
+ actions.each do |action|
23
+ @action = action
24
+ mustache_view_path = File.join(base_mustache_view_path,
25
+ "#{action}.rb")
26
+ mustache_template_path = File.join(base_mustache_template_path,
27
+ "#{action}.#{Stache.template_extension}")
28
+
29
+ template "view.rb.erb", mustache_view_path
30
+ template "view.html.mustache.erb", mustache_template_path
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ # Methods not to be executed go here
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ module <%= singular_name.camelize %>
2
+ class <%= @action.camelize %> < <%= @base_class %>
3
+
4
+ end
5
+ end
@@ -11,7 +11,7 @@ module Stache
11
11
  # use :mustache # or :handlebars
12
12
  # end
13
13
  module Config
14
- attr_accessor :template_base_path, :shared_path, :wrapper_module_name, :include_path_in_id, :template_cache
14
+ attr_accessor :template_base_path, :template_extension, :template_base_class, :shared_path, :wrapper_module_name, :include_path_in_id, :template_cache
15
15
 
16
16
  def configure
17
17
  yield self
@@ -25,6 +25,22 @@ module Stache
25
25
  @template_base_path = Pathname.new(path)
26
26
  end
27
27
 
28
+ def template_extension
29
+ @template_extension ||= 'html.mustache'
30
+ end
31
+
32
+ def template_extension= value
33
+ @template_extension = value
34
+ end
35
+
36
+ def template_base_class
37
+ @template_base_class ||= '::Stache::Mustache::View'
38
+ end
39
+
40
+ def template_base_class= value
41
+ @template_base_class = value
42
+ end
43
+
28
44
  def shared_path
29
45
  @shared_path ||= ::Rails.root.join('app', 'templates', 'shared')
30
46
  end
@@ -38,7 +38,9 @@ module Stache
38
38
  mustache.context.push(local_assigns)
39
39
  variables = controller.instance_variables
40
40
  variables.delete(:@template)
41
- variables -= controller.class.protected_instance_variables.to_a
41
+ if controller.class.respond_to?(:protected_instance_variables)
42
+ variables -= controller.class.protected_instance_variables.to_a
43
+ end
42
44
 
43
45
  variables.each do |name|
44
46
  mustache.instance_variable_set(name, controller.instance_variable_get(name))
@@ -1,3 +1,3 @@
1
1
  module Stache
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -15,7 +15,11 @@ module Stache
15
15
  end
16
16
 
17
17
  def self.included(source)
18
- source.send(:before_filter, :set_current_view_context) if source.respond_to?(:before_filter)
18
+ if source.respond_to?(:before_action) # Rails 4+
19
+ source.send(:before_action, :set_current_view_context)
20
+ elsif source.respond_to?(:before_filter) # Rails 3
21
+ source.send(:before_filter, :set_current_view_context)
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.name = 'stache'
6
6
  s.version = Stache::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ['Matt Wilson']
8
+ s.authors = ['Matt Wilson','Michael Bester']
9
9
  s.email = 'mhw@hypomodern.com'
10
10
  s.homepage = 'http://github.com/agoragames/stache'
11
11
  s.summary = %Q{A Rails 3.x and Rails 4.x compatible Mustache/Handlebars template handler}
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'rspec', '~>2.99.0'
32
32
  s.add_development_dependency 'rspec-rails', '~>2.99.0'
33
33
  s.add_development_dependency 'bundler'
34
- s.add_development_dependency 'rake'
34
+ s.add_development_dependency 'rake', '< 11.0'
35
35
  s.add_development_dependency 'test-unit'
36
36
  end
37
37
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
+ - Michael Bester
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-03-19 00:00:00.000000000 Z
12
+ date: 2017-02-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: mustache
@@ -98,16 +99,16 @@ dependencies:
98
99
  name: rake
99
100
  requirement: !ruby/object:Gem::Requirement
100
101
  requirements:
101
- - - ">="
102
+ - - "<"
102
103
  - !ruby/object:Gem::Version
103
- version: '0'
104
+ version: '11.0'
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
- - - ">="
109
+ - - "<"
109
110
  - !ruby/object:Gem::Version
110
- version: '0'
111
+ version: '11.0'
111
112
  - !ruby/object:Gem::Dependency
112
113
  name: test-unit
113
114
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +142,10 @@ files:
141
142
  - LICENSE
142
143
  - README.md
143
144
  - Rakefile
145
+ - lib/generators/stache.rb
146
+ - lib/generators/stache/controller/controller_generator.rb
147
+ - lib/generators/stache/controller/templates/view.html.mustache.erb
148
+ - lib/generators/stache/controller/templates/view.rb.erb
144
149
  - lib/stache.rb
145
150
  - lib/stache/asset_helper.rb
146
151
  - lib/stache/config.rb