Skip to content

FranklinChen/stack-templates

 
 

Repository files navigation

A repository for templates used by stack new. See: https://github.com/commercialhaskell/stack

Introduction

Project templates are written in hsfiles format, using mustache. Each file is specified with START_FILE, like this:

{-# START_FILE {{name}}.cabal #-}
name:                {{name}}
version:             0.1.0.0
...

Parameters to the template are written {{foo}}. They are provided by users via their ~/.stack/stack.yaml file, like this:

templates:
  params:
    author-email: chrisdone@gmail.com
    author-name: Chris Done
    copyright: 2015 Chris Done
    github-username: chrisdone
    category: Development

When the user runs stack new myproject yourtemplate and they do not have the parameters provided in, it will warn the user that such parameters were missing, like this:

$ stack new foo new-template
Downloading template "new-template" to create project "foo" in foo/ ...
The following parameters were needed by the template but not provided: author-email, author-name
You can provide them in /home/chris/.stack/stack.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
Or you can pass each one as parameters like this:
stack new foo new-template -p "author-email:value" -p "author-name:value"

The output of the template will yield a blank space where your parameter was. If you want to provide default values for your template parameters, use this Mustache syntax:

author:              {{author-name}}{{^author-name}}Author name here{{/author-name}}

Releases

No releases published

Packages

No packages published