Commit 7e45be8a authored by jejacks0n's avatar jejacks0n

Add ability to render readme templates

- This pretty much mimics the way that Thor, or more appropriately,
Rails generators renders templates.
parent e571ceb8
......@@ -3,6 +3,7 @@
module Projects
class CreateService < BaseService
include ValidatesClassificationLabel
TEMPLATE_PATH = Rails.root.join('app', 'services', 'projects', 'create_service', 'templates')
def initialize(user, params)
@current_user = user
......@@ -151,12 +152,16 @@ module Projects
branch_name: @default_branch.presence || @project.default_branch_or_main,
commit_message: 'Initial commit',
file_path: 'README.md',
file_content: "# #{@project.name}\n\n#{@project.description}"
file_content: template('readme_basic.md')
}
Files::CreateService.new(@project, current_user, commit_attrs).execute
end
def template(name)
ERB.new(File.read(TEMPLATE_PATH.join("#{name}.tt")), trim_mode: '<>').result(binding)
end
def skip_wiki?
!@project.feature_available?(:wiki, current_user) || @skip_wiki
end
......
# <%= @project.name %>
<%= @project.description %>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment