Mix v1.1.1 Mix.Generator

Conveniences for working with paths and generating content.

All of those functions are verbose, in the sense they log the action to be performed via Mix.shell/0.

Summary

Functions

Creates a directory if one does not exist yet

Creates a file with the given contents. If the file already exists, asks for user confirmation

Macros

Embeds a template given by contents into the current module

Embeds a text given by contents into the current module

Functions

create_directory(path)

Creates a directory if one does not exist yet.

create_file(path, contents, opts \\ [])

Creates a file with the given contents. If the file already exists, asks for user confirmation.

Options

  • :force - forces installation without a shell prompt.

Macros

embed_template(name, contents)

Embeds a template given by contents into the current module.

It will define a private function with the name followed by _template that expects assigns as arguments.

This function must be invoked passing a keyword list. Each key in the keyword list can be accessed in the template using the @ macro.

For more information, check EEx.SmartEngine.

embed_text(name, contents)

Embeds a text given by contents into the current module.

It will define a private function with the name followed by _text that expects no argument.