icecave/slate

This package is abandoned and no longer maintained. No replacement package was suggested.

A template engine for filesystem structures.

1.0.0 2014-09-09 09:58 UTC

This package is not auto-updated.

Last update: 2019-05-28 03:19:56 UTC


README

Build Status Test Coverage SemVer

Slate is a utility for creating directory and file structures from templates.

Slate was originally conceived to simplify and expedite the process of creating new repositories on GitHub, but can be used in any situation where a filesystem structure must be created from a template, such as user home directories, placeholder websites, filesystem based test fixtures, etc.

Prior to version 0.4.0 Slate was named Chassis.

Template format

A template is simply a collection of files and directories structured in the desired way, similar to /etc/skel on Unix systems. File and directory names may contain variables that will be substituted for other values when the template is cloned.

Variables

Variables are expressed as a variable name enclosed in braces, eg: {foo}. Variable names are case-sensitive and may contain letters, digits and the hyphen (-) character. Variables names must begin with a letter.

Variables can be escaped by prefixing the variable name with a backslash, eg: {\foo}. This prevents Slate from substituing the variable value and results in the output {foo}.

Slate can also substitute variable values inside text files. Any file with a .slate extension is passed through the template engine and the .slate extension is removed.

Variable transforms

Variable values can be modified by using a transform. A transform is specified using a pipe character (|) and transform name after the variable name. For example, {foo|lowercase} will convert the value of the foo variable to lower case in the output.

The following transforms are available:

  • base64-decode
  • base64-encode
  • camelcase
  • hex-decode
  • hex-encode
  • html-decode
  • html-encode
  • json-decode
  • json-encode
  • lowercase
  • lowercase-first
  • md5
  • newline-to-br
  • pluralize
  • rot13
  • sha1
  • singularize
  • snakecase
  • studlycaps
  • trim
  • trim-left
  • trim-right
  • uppercase
  • uppercase-first
  • url-decode
  • url-encode
  • yaml-decode
  • yaml-encode

Example templates

The Icecave Studios PHP template is a real-world example of a Slate template that we use when creating new PHP projects.

Usage

To create a filesystem structure from a template, use the clone command.

The following command clones from a template located in /path/to/template and writes the output to /path/to/output with the variable {foo} substituted with bar.

slate clone --define foo=bar --path /path/to/template /path/to/output

Slate will prompt for undefined variable values it requires, unless the --no-interaction option is used, in which case missing variable values will result in an error.

Online templates

Slate provides a set of online templates at https://github.com/IcecaveStudios/slate-templates. To use one of these templates pass the --template option to the clone command (instead of --path).

The following command clones the Icecave Studios PHP template to the /path/to/output folder.

slate clone --template php-icecave /path/to/output

Contact us