Allow templates to include the file name as a macro
This commit is contained in:
@ -11,7 +11,9 @@ module CodeOcean
|
|||||||
def create
|
def create
|
||||||
@file = CodeOcean::File.new(file_params)
|
@file = CodeOcean::File.new(file_params)
|
||||||
if @file.file_template_id
|
if @file.file_template_id
|
||||||
@file.content = FileTemplate.find(@file.file_template_id).content
|
content = FileTemplate.find(@file.file_template_id).content
|
||||||
|
content.sub! '{{file_name}}', @file.name
|
||||||
|
@file.content = content
|
||||||
end
|
end
|
||||||
authorize!
|
authorize!
|
||||||
create_and_respond(object: @file, path: proc { implement_exercise_path(@file.context.exercise, tab: 2) })
|
create_and_respond(object: @file, path: proc { implement_exercise_path(@file.context.exercise, tab: 2) })
|
||||||
|
Reference in New Issue
Block a user