Refactor dm_template to script_template