adzap-mustache-rails 0.2.4 → 0.2.5

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: 476d2c75a92363ebef330cbb423b7183aad959f1
4
- data.tar.gz: d21198323052cce261c2e52130bb3b909132a5bf
3
+ metadata.gz: de5b2e1a81eb8c9283994b380049696394abe2ab
4
+ data.tar.gz: 5b9578c07720c7b130171538b8323bf4a8aaa0ec
5
5
  SHA512:
6
- metadata.gz: 8c5856b23fe7adfc323abfba3367f28ca33a65933ba88024131f7bb4ee33061ad7b910b1842fb479e703e220c132675782949cde5c1824fdd0d9b61927803c67
7
- data.tar.gz: ac72e5de3f91c03e5ed7cd3cf272bb8f16b5cba0fe3d6cd0da0220a7eef5fe0fb33e6a35da7ace9c4f1db8a2422c210cc128eb72fc6de2daa85e8e58450f39d6
6
+ metadata.gz: 8bfe1f0748f97615aca1995fc39a504f1c6bcf064cb5ffd1ff345dd73e6c09753299bbb51397d8f33e8c78400f3d90e379892a055258c48afd22b4cb56d6ee69
7
+ data.tar.gz: dc20733ee1b652b776a0e31ba8e7d7a7048740573cf79355649cddcbfc145d41c696999dea2660c9f6df3fd8cc2bb9bda189a2fba56f75d0bf0fe0d18b3600c3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mustache Rails
2
2
 
3
- Implements Mustache views and templates for Rails 3.x
3
+ Implements Mustache views and templates for Rails 3+
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,4 +1,5 @@
1
1
  require 'action_view'
2
+ require 'action_dispatch'
2
3
  require 'mustache'
3
4
 
4
5
  module ActionView
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/named_base'
2
+
3
+ class Mustache # :nodoc:
4
+ module Generators # :nodoc:
5
+ class Base < Rails::Generators::NamedBase #:nodoc:
6
+ protected
7
+
8
+ def formats
9
+ [format]
10
+ end
11
+
12
+ def format
13
+ :html
14
+ end
15
+
16
+ def handler
17
+ :mustache
18
+ end
19
+
20
+ def filename_with_extensions(name, format = self.format)
21
+ [name, format, handler].compact.join(".")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'generators/mustache'
2
+
3
+ class Mustache # :nodoc:
4
+ module Generators # :nodoc:
5
+ class ControllerGenerator < Base # :nodoc:
6
+ argument :actions, type: :array, default: [], banner: "action action"
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def copy_view_files
11
+ empty_directory File.join("app/views", class_path, file_name)
12
+ empty_directory File.join("app/templates", class_path, file_name)
13
+
14
+ actions.each do |action|
15
+ @action = action
16
+ template 'view.rb', File.join("app/views", class_path, file_name, "#{action}.rb")
17
+
18
+ formats.each do |format|
19
+ template filename_with_extensions(:view, format), File.join("app/templates", class_path, file_name, filename_with_extensions(action, format))
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ module Views
2
+ module <%= class_name %>
3
+ class <%= @action.titleize %> < <%= Rails.configuration.mustache.view_base_class %>
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ require 'generators/mustache'
2
+ require 'rails/generators/resource_helpers'
3
+
4
+ class Mustache # :nodoc:
5
+ module Generators # :nodoc:
6
+ class ScaffoldGenerator < Base # :nodoc:
7
+ include Rails::Generators::ResourceHelpers
8
+
9
+ source_root File.expand_path("../templates", __FILE__)
10
+
11
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
12
+
13
+ def create_root_folder
14
+ empty_directory File.join("app/views", controller_file_path)
15
+ empty_directory File.join("app/templates", controller_file_path)
16
+ end
17
+
18
+ def copy_view_files
19
+ available_views.each do |view|
20
+ @action = view
21
+
22
+ formats.each do |format|
23
+ template_filename = filename_with_extensions(view, format)
24
+
25
+ template template_filename, File.join("app/templates", controller_file_path, template_filename)
26
+ template "view.rb", File.join("app/views", controller_file_path, "#{view}.rb")
27
+ end
28
+ end
29
+ end
30
+
31
+ protected
32
+
33
+ def available_views
34
+ %w(index edit show new _form)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ module Views
2
+ module <%= class_name %>
3
+ class <%= @action.titleize %> < <%= Rails.configuration.mustache.view_base_class %>
4
+ end
5
+ end
6
+ end
@@ -60,6 +60,15 @@ class Mustache
60
60
  # Returns nil, String or Class.
61
61
  config.mustache.default_view_class = nil
62
62
 
63
+ # Public: Set Mustache View base class to use.
64
+ #
65
+ # Defaults to base class provided by gem (ActionView::Mustache)
66
+ # but can be changed to another base class to override the parent
67
+ # class name output by view generators.
68
+ #
69
+ # Returns String or Class.
70
+ config.mustache.view_base_class = 'ActionView::Mustache'
71
+
63
72
  # Internal: Ensures view path is included in autoload path.
64
73
  initializer 'mustache.add_autoload_paths', :before => :set_autoload_paths do |app|
65
74
  app.config.autoload_paths << app.root.join(app.config.mustache.view_path).to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adzap-mustache-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
- - Joshua Peek
7
+ - Adam Meehan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -59,7 +59,7 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  description: Implements Mustache views and templates for Rails 4.0
62
- email: josh@joshpeek.com
62
+ email: adam.meehan@gmail.com
63
63
  executables: []
64
64
  extensions: []
65
65
  extra_rdoc_files: []
@@ -70,6 +70,17 @@ files:
70
70
  - lib/action_view/mustache/context.rb
71
71
  - lib/action_view/mustache/generator.rb
72
72
  - lib/action_view/template/handlers/mustache.rb
73
+ - lib/generators/mustache.rb
74
+ - lib/generators/mustache/controller/controller_generator.rb
75
+ - lib/generators/mustache/controller/templates/view.html.mustache
76
+ - lib/generators/mustache/controller/templates/view.rb
77
+ - lib/generators/mustache/scaffold/scaffold_generator.rb
78
+ - lib/generators/mustache/scaffold/templates/_form.html.mustache
79
+ - lib/generators/mustache/scaffold/templates/edit.html.mustache
80
+ - lib/generators/mustache/scaffold/templates/index.html.mustache
81
+ - lib/generators/mustache/scaffold/templates/new.html.mustache
82
+ - lib/generators/mustache/scaffold/templates/show.html.mustache
83
+ - lib/generators/mustache/scaffold/templates/view.rb
73
84
  - lib/mustache/railtie.rb
74
85
  homepage: https://github.com/josh/mustache-rails
75
86
  licenses: []