0.1.3 • Published 1 year ago

saladplate v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Saladplate

Simple templating; it's smaller than usual.

Saladplate is a very simple templating tool, with 3 features:

  1. Replace ${{ VAR }} with the contents of the environment variable VAR.
  2. Replace $<< filename >> with the contents of the file filename.
  3. Replace $(( some command )) with the output of the command some command.

If you need more functionality that that, this is not the templating tool for you.

Installation

$ npm -g install saladplate
$ saladplate --version
saladplate: version 0.1.2

Usage

The easiest way to use Saladplate with via the saladplate command line tool:

$ saladplate --help

Usage: saladplate [options] <file>...
Options:
  --debug          enable debug mode
  -v, --version    show version information
  -h, --help       show this help message
  -d, --directory  output directory
  -s, --suffix     output suffix; only applies when using --directory
  -o, --output     output file; overrides --directory and --suffix

Saladplate generally operates in 2 modes. If you pass --directory, then each file you pass will be templated independently, and the output written into the given directory. Use --suffix to change the extension of the output file -- for instance, if you template the files some.template and another.txt with --directory=out and --suffix=.html you will end up with a file out/some.html and out/another.html:

$ saladplate --directory=out --suffix=.html *.template

If instead you pass --output, then each file will be templated, with the results concatenated into the single given output file.

$ saladplate --output=index.html *.template

You can also use the exported template function to template a string:

import { template } from "saladplate";
console.info(template("The current PATH is: $PATH"));

Development

When developing locally, you can test your changes using the script saladplate, which uses ts-node. Note the use of run below, as well as the use of -- to separate arguments to npm run from arguments to saladplate:

$ npm run saladplate -- --version

> saladplate@0.1.2 saladplate
> ts-node ./bin/saladplate.ts

saladplate: version 0.1.2

Building and publishing

To build the distributable JS:

$ npm run build

This will build to dist/. To publish to NPM:

$ npm publish

Testing

Tests are located in tests/ and consist of input templates tests/*.test and corresponding expected outputs tests/*.expected. To run tests:

$ npm run test
0.1.3

1 year ago

0.1.2

1 year ago

0.1.1-a

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago