diff --git a/README.md b/README.md
index 0946094..d1a0cb0 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ If you want to use another theme, instead of the default, you can use the `--the
rails g web_app_theme:theme admin --theme="drastic-dark"
-You can specify the template engine with `--engine=name` option, where name can be erb (default) or haml:
+You can specify the template engine with `--engine=name` option, where name can be erb (default), haml or slim (requires haml2slim and hpricot):
rails g web_app_theme:theme --engine=haml # you must specify haml in your Gemfile
@@ -69,7 +69,7 @@ If the controller has a name different to the model used, specify the controller
rails g web_app_theme:themed admin/items post
-If you use `will_paginate` for pagination use the `--will-paginate`:
+If you use a pagination gem like `will_paginate` or `kaminari`, use the `--will-paginate` or `--kaminari`:
rails g web_app_theme:themed items post --will-paginate
@@ -156,4 +156,4 @@ Credits
-------
* Icons: FAMFAMFAM Silk icons
-* Buttons: Particletree - Rediscovering the Button Element
\ No newline at end of file
+* Buttons: Particletree - Rediscovering the Button Element
diff --git a/lib/generators/web_app_theme/theme/theme_generator.rb b/lib/generators/web_app_theme/theme/theme_generator.rb
index bd3acf0..72324f7 100644
--- a/lib/generators/web_app_theme/theme/theme_generator.rb
+++ b/lib/generators/web_app_theme/theme/theme_generator.rb
@@ -18,6 +18,8 @@ def copy_layout
template admin_layout_name, "app/views/layouts/#{layout_name.underscore}.html.erb"
when 'haml'
generate_haml_layout(admin_layout_name)
+ when 'slim'
+ generate_slim_layout(admin_layout_name)
end
end
@@ -57,5 +59,21 @@ def generate_haml_layout(admin_layout_name)
say "HAML is not installed, or it is not specified in your Gemfile."
exit
end
+
+ def generate_slim_layout(admin_layout_name)
+ require 'haml2slim'
+ Dir.mktmpdir('web-app-theme-slim') do |slim_root|
+ tmp_html_path = "#{slim_root}/#{admin_layout_name}"
+ tmp_haml_path = "#{slim_root}/#{admin_layout_name}.haml"
+ tmp_slim_path = "#{slim_root}/#{admin_layout_name}.slim"
+ template admin_layout_name, tmp_html_path, :verbose => false
+ `html2haml --erb --xhtml #{tmp_html_path} #{tmp_haml_path}`
+ `haml2slim #{tmp_haml_path} #{tmp_slim_path}`
+ copy_file tmp_slim_path, "app/views/layouts/#{layout_name.underscore}.html.slim"
+ end
+ rescue LoadError
+ say "haml2slim not installed, or it is not specified in your Gemfile."
+ exit
+ end
end
end
diff --git a/lib/generators/web_app_theme/themed/templates/view_tables.html.erb b/lib/generators/web_app_theme/themed/templates/view_tables.html.erb
index c8006e0..cb09361 100644
--- a/lib/generators/web_app_theme/themed/templates/view_tables.html.erb
+++ b/lib/generators/web_app_theme/themed/templates/view_tables.html.erb
@@ -46,6 +46,9 @@
<% if options.will_paginate %>
<%%= will_paginate @<%= plural_resource_name %> %>
<% end %>
+ <% if options.kaminari %>
+ <%%= paginate @<%= plural_resource_name %> %>
+ <% end %>
diff --git a/lib/generators/web_app_theme/themed/themed_generator.rb b/lib/generators/web_app_theme/themed/themed_generator.rb
index 44d3a63..858214b 100644
--- a/lib/generators/web_app_theme/themed/themed_generator.rb
+++ b/lib/generators/web_app_theme/themed/themed_generator.rb
@@ -10,6 +10,7 @@ class ThemedGenerator < Rails::Generators::Base
class_option :layout, :type => :string, :desc => 'Specify the layout name'
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
class_option :will_paginate, :type => :boolean, :default => false, :desc => 'Specify if you use will_paginate'
+ class_option :kaminari, :type => :boolean, :default => false, :desc => 'Specify if you use kaminari'
class_option :themed_type, :type => :string, :default => 'crud', :desc => 'Specify the themed type, crud or text. Default is crud'
def initialize(args, *options)