Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

new

Raynes edited this page · 2 revisions

Cake has an extremely fiexible new command. You can define project templates in ~/.cake/templates/. If you don't, the first time you use cake new a default template directory will be created for you in ~/.cake/templates/default/, and this template will be used whenever you don't explicitly specify which template to use when calling cake new.

You can create a new template by calling cake new template foo, or by coping the default template to a new template directory. For example cp -r ~/.cake/templates/default ~/.cake/templates/foo. Either way, a new template will be created under the name of foo.

In a template, you can salt your files, filenames, and subdirectories with a substitution token +project+. Whenever cake new is ran with that template, the template directory will be copied to the directory where you ran cake new, and it will be renamed to the name of your project. Cake will then look through the directory and will change all instances of +project+ to the name of your project. It will look in all of the files, filenames, and subdirectories.

For example, if you set up '~/.cake/templates/foo` to have this structure:

  • src/
    • +project+/
      • core.clj -> containing "(ns +project+.core)"
  • test/

then running cake new myproject will result in a myproject/ directory with this structure:

  • src/
    • myproject/
      • core.clj -> containing "(ns myproject.core)"
  • test/

You're welcome to edit the default template directory to your hearts desire and create as many templates as you like. If, for this new project, you do not want to use the default template, you can specify which template to use like so: cake new foo bar, where foo is the name of the template and bar is the name of the project you want to create with the template. Your project template can be as complex as you like. Be careful about storing very large files in your template directory, because cake will have to look through it in order to replace +project+.

The idea behind having templates like this is that you can have a new project template for whatever type of projects you work with. You can have one for generic projects, one or web projects, etc.

They are also designed for simplicity. If you don't care about templates and like the default template, you don't even have to bother with them. The first time you run cake new to create a new project, the default template directory is created and used for you, and you don't have to touch it unless you really want to.

Something went wrong with that request. Please try again.