mix_templates v0.1.0 MixTemplates
This is the engine that supports templated directory trees.
A template is a trivial mix project. It contains a single source file
in lib that contains metadata and option parsing. It also contains a
top-level directpry called template. The directories and files
underneath template/ copied to the destination location.
The copying function tasks a map containing key-value pairs. This is
passed to EEx, which is used to expand each individual file. Thus a
template file for mix.exs may contain:
defmodule <%= @project_name_camel_case %>.Mixfile do
use Mix.Project
@name :<%= @project_name %>
@version "0.1.0"
The `<%= ... %>` constructs are expanded using the passed in map.
In addition, the template looks for the string `$PROJECT_NAME$` in the
_names_ of files and directories. It replaces each occurrence with the
name of the project, taken from `assigns.project_name`.
Thus the directory structure for a standard Elixir project might be:
template
├── $PROJECT_NAME$
│ ├── README.md
│ ├── config
│ │ └── config.exs
│ ├── lib
│ │ └── $PROJECT_NAME$.ex
│ ├── mix.exs
│ └── test
│ ├── $PROJECT_NAME$_test.exs
│ └── test_helper.exs
└── templates_project.ex
## Usage
Although MixTemplates provides a programmatic API for finding, listing, and
installing templates, it is normally invoked via mix tasks. The
templates themselves are managed by the `mix template` task.
Generating projects using them is controlled by `mix gen`.
Templates must be installed before use. This is done using the `mix
template` task.
* mix template
* `mix template [list]`
List the locally installed templates.
* `mix template hex`
List the templates available on hex.
* `mix template install «source»`
Install a template from source.
* `mix template uninstall «name»`
Uninstall the template with the given name.
The «source» can be
* the name of a Hex project containing the template
* a local file path (starting with a `.` or `/`)
Templates are installed in MIX_HOME/templates (by default ~/.mix/templates).
## Installation
$ mix archive.install hex mix_templates
$ mix archive.install hex mix_task_gen