npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tmpltr

v1.1.4

Published

Templating with mustache and YAML

Downloads

5

Readme

tmpltr - templating files with mustache and YAML

__       __                  ____      
\ \     / /_____ ___  ____  / / /______
 \ \   / __/ __ `__ \/ __ \/ / __/ ___/
 / /  / /_/ / / / / / /_/ / / /_/ /    
/_/   \__/_/ /_/ /_/ .___/_/\__/_/     
                  /_/                  

Concept

This tool generates a set of files based on one or more templates in combination with a set of values used as tempalte variables.
For tempaltes, mustache is used. For the manifest file, YAML is used (*.yaml and *.yml are equally supported).
For execution, at least one *.mustache template and one *.yml manifest file are required.

Usage

tmpltr [workingDirectory] [--manifest <manifest yml file>] [--verbose] [--dryrun] [--console]

Options and switches

| option | optional | default | description | |------------------|----------|---------|--------------------------------------------------------------------------------------------------------------| | workingDirectory | true | . | working directory in which to search for the templates and the manifest.yml files (if not further specified) | | --verbose | true | false | increased output on "debug" level | | --dryrun | true | false | do not write any templated files | | --console | true | false | print the templated files to the console | | --manifest | true | '' | location of the manifest.yml file. absolute or relative to the pwd | | --stdin | true | false | reads the manifest file data from stdin. useful for usage with secrets |

File structure

For mustache template files, please refer to the official documentation
manifest.yml file structure:

---
# list of files to be generated
files: 
    # destination file relative to the working directory
  - destination: ./foo.txt 
    # template file name. all template files must be in the working directory. 
    # *.mustache file extension is optional.
    template: my-template[.mustache] 
    # object of values to be rendered into the template
    values:
      foo: "foo"
      bar: "bar"
      fizzBuzz: 42

Locating the manifest file

The --manifest switch of the tmpltr command can be used to specify the manifest file. It has highest priority and is considered to be either absolute or relative to the pwd.

/home/
├─ some-project/
│  ├─ templates/
│  │  ├─ manifest.yml
│  │  ├─ template-a.mustache
│  │  ├─ template-b.mustache
│  ├─ README.md
│  ├─ my-manifest.yml
cd /home/some-project/
tmpltr --manifest ./my-manifest.yml templates
# equivalent to
tmpltr --manifest /home/some-project/my-manifest.yml templates

If no --manifest switch is specified, the manifest.y[a]ml file is searched in the working directory.

cd /home/some-project/
tmpltr templates # uses the manifest.yml file in the templates directory
# equivalet to
cd /home/some-project/templates/
tmpltr # uses the pwd (/home/some-project/templates/) as working directory and uses the manifest.yml file

If no manifest.y[a]ml file is found, all *.y[a]ml files in the working directory are considered to be manifest files and checked against the YAML validator.

/home/
├─ some-project/
│  ├─ templates/
│  │  ├─ manifest-a.yml
│  │  ├─ manifest-b.yaml
│  │  ├─ template-a.mustache
│  │  ├─ template-b.mustache
│  ├─ README.md
│  ├─ my-manifest.yml
cd /home/some-project/
tmpltr templates # uses manifest-a.yml AND manifest-b.yaml

With npm/npx

npm i -g tmpltr
# OR
npx tmpltr

With docker

docker run --rm -v ${PWD}:/usr/src mxcd/tmpltr

Made with ♥, pizza and beer by MaPa