-
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.
[#492] Update template code and slim template index file
- Loading branch information
1 parent
56bd163
commit 6742028
Showing
4 changed files
with
52 additions
and
0 deletions.
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
def copy_template_files | ||
copy_non_tt_files | ||
copy_tt_files | ||
end | ||
|
||
def copy_non_tt_files | ||
# The reason we are excluding .tt files is because | ||
# this directory method will actually apply the template and remove the .tt extension in the destination | ||
directory 'lib/templates', exclude_pattern: /.*\.tt$/ | ||
end | ||
|
||
def copy_tt_files | ||
src_path = File.join(__dir__, 'templates') | ||
dst_path = 'lib/templates' | ||
|
||
Dir.glob("#{src_path}/**/*.tt").sort.each do |file_source| | ||
relative_path = file_source.gsub("#{src_path}/", "") | ||
|
||
copy_file(file_source, File.join(dst_path, relative_path)) | ||
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