Packages

A template for building Elixir libraries (projects without any state, just functions). This project is an extremely paired down version of `mix new «project_name»` based on Dave Thomas' view of simplifying our Elixir code. Let's see how this plays out.

Current section

Files

Jump to
gen_template_library lib gen_template_component.ex
Raw

lib/gen_template_component.ex

defmodule GenTemplateLibrary do
@moduledoc """
# Templates for Elixir projects that contain state
Based on the keynote by [Dave Thomas](https://pragdave.me/)
at [Empex NYC 2018](http://empex.co/events/2018/conference.html) about
how we are all writing Elixir incorrectly.
## Bootstrap
Before you can use this template (or any other template), you need to install
[mix gen](https://github.com/pragdave/mix_generator).
This template is installed using the `template.install` mix task.
Projects are generated from it using the `mix gen` task.
So, before using templates for the first time, you need to install these two tasks:
$ mix archive.install mix_templates
$ mix archive.install mix_generator
Then you can install this template using
$ mix template.install gen_template_library
## New Library
To generate your new Elixir library
mix gen library «name» [ --into «path» ] [--module «module»]
«Module» must be a valid Elixir module name or alias.
"""
use MixTemplates,
name: :library,
short_desc: "An Elixir project that just provides functions, no state required",
source_dir: "../template",
options: [
module: [
to: :project_name_camel_case,
required: false,
takes: "«project_name»",
desc: "sets the name of the module to «project_name»"
]
]
end