# pug-tree

> Compiles pug templates into an object representation based on the pug template directory structure

Latest version **1.0.4** (published 2024-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install pug-tree
pnpm add pug-tree
yarn add pug-tree
bun add pug-tree
```

## Health

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

Positive: no vulnerabilities; has provenance.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2024-06-19 |
| First published | 2017-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | DJ Ambrisco |
| Maintainers | dambrisco |
| Keywords | pug, directory, tree, compile, template |

## Links

- npm: https://www.npmjs.com/package/pug-tree
- Repository: https://github.com/dambrisco/pug-tree
- Homepage: https://github.com/dambrisco/pug-tree#readme
- Issues: https://github.com/dambrisco/pug-tree/issues
- npm.io page: https://npm.io/package/pug-tree

## Dependencies (1)

- [pug](https://npm.io/package/pug.md) ^3.0.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2024-06-19
- 1.0.5 — 2024-06-19
- 1.0.3 — 2024-06-19
- 1.0.2 — 2023-06-06
- 1.0.1 — 2017-06-15
- 1.0.0 — 2017-06-14

## README

[![pug-tree](https://raw.githubusercontent.com/dambrisco/pug-tree/master/pug-tree.jpg)](https://raw.githubusercontent.com/dambrisco/pug-tree/master/pug-tree.jpg)  
[Credit: flickr/dapuglet](https://www.flickr.com/photos/dapuglet)

# pug-tree
[![NPM version](https://img.shields.io/npm/v/pug-tree?logo=npm)](https://npmjs.org/package/pug-tree "View this project on NPM")
[![Dependency status](https://img.shields.io/librariesio/github/dambrisco/pug-tree?logo=librariesio)](https://libraries.io/github/dambrisco/pug-tree "View this project on Libraries.io")
[![CI status](https://img.shields.io/github/actions/workflow/status/dambrisco/pug-tree/node.js.yml?logo=github)](https://github.com/dambrisco/pug-tree/actions/workflows/node.js.yml?query=branch%3Atrunk "View this project's CI run history")

pug-tree is a tiny library design to build nested objects of templating functions from a given directory of [pug template](https://github.com/pugjs/pug) files.

## Installation and Usage

* `npm install --save pug-tree`
* `require('pug-tree')(directory, defaults)`
  * `directory` should be the top level of your templates folder, usually something like `path.join(__dirname, 'templates')`
  * `defaults` is properties object that is pre-bound to template - this is a good place to include information that doesn't usually change like `title`
  * See `test/test.js` for usage example

Given a folder structure:
```
<project-name>
↳ templates
  ↳ index.pug
  ↳ nested
    ↳ page.pug
```

You will be able to do the following:
```node
var templates = require('pug-tree')(path.join(__dirname, 'templates'), { title: title })
var indexHtml = templates.index({ body: indexBody })
var nestedPageHtml = templates.nested.page({ body: nestedPageBody })
```

Where `title` and `body` are both available to each of the templates.

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