8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/page_generator.rb', line 8
def create(page_name)
template_content = File.read(File.join(TEMPLATE_SOURCE, 'page.jsx.tt'))
template = ERB.new(template_content)
page_name_capitalized = page_name.split('_').map(&:capitalize).join
result = template.result_with_hash(
page_name_capitalized: page_name_capitalized,
page_name: page_name
)
dir_path = "frontend/src/app/#{page_name}"
FileUtils.mkdir_p(dir_path)
File.write("#{dir_path}/page.jsx", result)
end
|