Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#492][CRUD] Add the index view templates to the generator #505

Merged
merged 12 commits into from
Mar 13, 2024
17 changes: 5 additions & 12 deletions .template/addons/crud/lib/template.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# frozen_string_literal: true

require File.expand_path('../../../lib/thor_utils', __dir__)

use_source_path __dir__

def copy_template_files
ignore_tt do
::ThorUtils.ignore_tt do
directory 'lib/templates', renderTemplates: false
end
end

def 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

copy_template_files
12 changes: 12 additions & 0 deletions .template/lib/thor_utils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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
khangbui22 marked this conversation as resolved.
Show resolved Hide resolved
Loading