themplate: Project templating tool

[ application, bsd3, console, development, program, template ] [ Propose Tags ] [ Report a vulnerability ]

Themplate is a tool to generate projects from templates. The templating language is described at https://github.com/bennofs/themplate.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 1.1, 1.2
Dependencies base (>=4.4 && <5), configurator, directory, either, errors (>=2), filepath, optparse-applicative (>=0.10), text, transformers (>=0.2), transformers-compat (>=0.3) [details]
License BSD-3-Clause
Copyright Copyright (C) 2013-2014 Benno Fünfstück
Author Benno Fünfstück
Maintainer Benno Fünfstück <benno.fuenfstueck@gmail.com>
Revised Revision 1 made by BennoFuenfstueck at 2015-07-08T08:31:27Z
Category Application, Console, Development, Template
Home page http://github.com/bennofs/themplate/
Bug tracker http://github.com/bennofs/themplate/issues
Source repo head: git clone https://github.com/bennofs/themplate.git
Uploaded by BennoFuenfstueck at 2015-07-08T08:29:50Z
Distributions NixOS:1.2
Reverse Dependencies 1 direct, 0 indirect [details]
Executables themplate
Downloads 2824 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2016-12-08 [all 6 reports]

Readme for themplate-1.2

[back to package description]

Themplate

Build Status

This is a very simple program for creating project templates.

Installing Themplate

From hackage:

$ cabal install themplate

From repository:

Checkout the source code:

$ git clone https://github.com/bennofs/themplate
$ cd themplate

Build in a cabal sandbox and install:

$ cabal sandbox init
$ cabal install --prefix=~/.cabal   # Install themplate executable to ~/.cabal/bin/themplate

Using Themplate

To use a exisiting template with themplate, just run:

$ themplate init <project name> <template name>

This will initialize the template with the given name in a new directory with the name of the project. To list all available templates, run:

$ themplate list

Configuration file

The configuration file is read using configurator, the syntax is described here. The options are passed to the template, so they can use patterns to include user-specific information. An example configuration file could look like this:

user { 
  name = "Benno Fünfstück"
  email = "benno.fuenfstueck@gmail.com"
}

github {
  user = "bennofs"
}

This will make the options user.name, user.email and github.user available to templates.

Creating templates

A template is just a subdirectory in ~/.themplate. When a new project is created with the template, the files in that directory are copied to the project directory. The files contents and the file names in the template can contain patterns. Patterns are enclosed in {{ and }}. In a pattern, the following special forms are substituted:

  • $$name$$ will be substituted for the value of the configuration option name. An error is thrown if the configuration option doesn't exist.
  • ??name?? will be substituted for the value of the configuration option name. If the configuration option doesn't exist, the pattern will evaluate to the empty string.

There is one special configuration option, project.name. This will always be set to the current project's name. ??name?? patterns are checked prior to $$name$$ patterns, so the following:

{{homepage:      http://github.com/??github.user??/$$project.name$$/}}

won't throw an error if github.user is unset, even if project.name was unset.

You can find an example template at https://github.com/bennofs/dotfiles/tree/master/.themplate/.