-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [#483] Add tests to the CRUD layout * [#483] Fix the check for slim and erb layout files * [#492] Update Gemfile to include slim-rails instead of slim * [#492] Update template code and slim template index file * [#492] Fix rubocop issue * [#492] Fix spec test * [#492] Improve copy_template_files function for easier readability * [#492] Fix rubocop error * [#492] Remove unused method * [#492] Move ThorUtils to a lib * [#492] Fix rubocop * [#492] Fix rubocop --------- Co-authored-by: Xavier MALPARTY <[email protected]>
- Loading branch information
1 parent
cf33fad
commit 688614e
Showing
6 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path('../../../lib/thor_utils', __dir__) | ||
|
||
use_source_path __dir__ | ||
|
||
def copy_template_files | ||
ThorUtils.ignore_tt do | ||
directory 'lib/templates', renderTemplates: false | ||
end | ||
end | ||
|
||
copy_template_files |
21 changes: 21 additions & 0 deletions
21
.template/addons/crud/lib/templates/slim/scaffold/index.html.slim.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
h1 <%= human_name.pluralize %> | ||
|
||
#<%= plural_table_name %> | ||
table.table.table-hover.table-responsive | ||
thead | ||
tr | ||
<% attributes.each do |attribute| -%> | ||
th <%= attribute.human_name %> | ||
<% end -%> | ||
th colspan="3" | ||
tbody | ||
- @<%= plural_table_name %>.each do |<%= singular_table_name %>| | ||
tr | ||
<% attributes.each do |attribute| -%> | ||
td = <%= singular_table_name %>.<%= attribute.name %> | ||
<% end -%> | ||
td = link_to 'Show', <%= singular_table_name %>, class: 'btn btn-info' | ||
td = link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'btn btn-primary' | ||
td = link_to 'Destroy', <%= singular_table_name %>, data: { turbo_method: :delete, confirm: 'Are you sure' }, class: 'btn btn-danger' | ||
|
||
= link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %>, class: 'btn btn-success' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
@import 'layouts'; | ||
SCSS | ||
end | ||
|
||
apply 'lib/template.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class ThorUtils | ||
def self.ignore_tt | ||
# NOTE: change template extension so it would skip | ||
# `when /#{TEMPLATE_EXTNAME}$/` condition and | ||
# fallback to default `copy_file` | ||
Thor::TEMPLATE_EXTNAME.concat '_no_match' # => .tt_no_match | ||
yield | ||
ensure | ||
# NOTE: make sure to undo our dirty work after the block | ||
Thor::TEMPLATE_EXTNAME.chomp! '_no_match' # => .tt | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters