Mix v1.0.5 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.

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

Embed 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)

Embed 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.