module Cog::Controllers::TemplateController
Manage a project's templates
Public Class Methods
create(name, opt={})
click to toggle source
Create a new project template @param name [String] name of the template, relative to the project's templates directory @option opt [Boolean] :force_override (false) if a built-in or plugin template with the same name already exists, should a project override be created? @return [nil]
# File lib/cog/controllers/template_controller.rb, line 11 def self.create(name, opt={}) prefix = Cog.project_template_path raise Errors::ActionRequiresProjectTemplatePath.new('create template') unless prefix name = name.without_extension :erb dest = File.join prefix, "#{name}.erb" original = Generator.get_template name, :as_path => true Generator.copy_file_if_missing original, dest nil rescue Errors::NoSuchTemplate # No original, ok to create an empty template Generator.touch_file dest nil end
list()
click to toggle source
List the available templates @return [Array<String>] a list of templates
# File lib/cog/controllers/template_controller.rb, line 27 def self.list Helpers::CascadingSet.process_paths Cog.template_path, :ext => 'erb' end