# templa

> Simple template builder for static sites

Latest version **0.0.3** (published 2016-05-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install templa
pnpm add templa
yarn add templa
bun add templa
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-05-09 |
| First published | 2016-05-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Berman |
| Maintainers | scriptist |

## Links

- npm: https://www.npmjs.com/package/templa
- Repository: https://github.com/scriptist/templo
- Homepage: https://github.com/scriptist/templo#readme
- Issues: https://github.com/scriptist/templo/issues
- npm.io page: https://npm.io/package/templa

## Dependencies (5)

- [marked](https://npm.io/package/marked.md) ^0.3.5
- [mkpath](https://npm.io/package/mkpath.md) ^1.0.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.6.0
- [nunjucks](https://npm.io/package/nunjucks.md) ^2.4.2
- [yaml-front-matter](https://npm.io/package/yaml-front-matter.md) ^3.4.0

## Recent versions

- 0.0.3 (latest) — 2016-05-09
- 0.0.2 — 2016-05-09

## README

# Templa

Templa is a module for building static sites from data files and template files.

It can read data from yaml or json files, and also plain text or markdown with yaml/json front matter.

The magic happens in the `.templa.json` file:

```json
{
	"baseDataDir": "./src/data",
	"baseTemplateDir": "./src/templates",
	"templateExtension": "html.nunjucks",
	"outputDir": "./build",
	"globalData": [
		{
			"key": "sporks",
			"dir": "sporks"
		}
	],
	"pages": [
		{
			"url": "/",
			"template": "index"
		},
		{
			"url": "/another-static-page",
			"template": "static-page-template"
		},
		{
			"url": "/spork-path/:slug",
			"template": "spork-page",
			"data": {
				"dir": "sporks",
				"key": "spork"
			}
		}
	]
}
```

Now just run `templa()`.

First, this will read all the files in the `sporks` directory and store them as global data, accessible to all templates.

Next, it generates two static pages - `index.html` and `another-static-page.html` and store them in the `build` directory.

Finally, it will create one new page based on the `spork-page.html.nunjucks` template for every file in the `sporks` directory, and save them in the `build/spork-path` directory.

If you'd prefer to use a single data file rather than one for each page, just replace `"dir": "sporks"` with `"file": "sporks.yaml"`;

---
_Source: https://npm.io/package/templa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
