# pope

> Zero dependency micro templating engine for strings only.

Latest version **3.0.0** (published 2021-03-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-03-22 |
| First published | 2015-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | amanvirk |
| Maintainers | amanvirk, virk |
| Keywords | template, templating, string, string-template, micro, template |

## Links

- npm: https://www.npmjs.com/package/pope
- Repository: https://github.com/poppinss/pope
- Homepage: https://github.com/poppinss/pope#readme
- Issues: https://github.com/poppinss/pope/issues
- npm.io page: https://npm.io/package/pope

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-03-22
- 2.0.2 — 2017-12-13
- 2.0.0 — 2017-12-02
- 1.0.5 — 2017-12-02
- 1.0.4 — 2017-09-08
- 1.0.3 — 2017-09-07
- 1.0.2 — 2017-02-22
- 1.0.1 — 2017-02-13
- 1.0.0 — 2015-11-12

## README

# Pope

![](https://img.shields.io/travis/poppinss/pope.svg)
[![Coverage Status](https://coveralls.io/repos/poppinss/pope/badge.svg?branch=master&service=github)](https://coveralls.io/github/poppinss/pope?branch=master)

Pope is a fast, minimal and micro template engine for strings only, it plays well where you want to embed micro templates inside your module.

<details>
<summary> Upgrading from 1.x.x </summary>
The version <strong>2.0.x</strong> has a breaking change, where <code>pope</code> is not the default export, instead exported as a property on the object.

<h4> Earlier </h4>
<pre class="language-javascript">
<code>
const pope = require('pope')
</code>
</pre>

<h4> Now </h4>
<pre class="language-javascript">
<code>
const { pope } = require('pope')
</code>
</pre>
</details>

## Examples

### string interpolation
```javascript
const { pope } = require('pope')
pope('There are {{count}} emails in your inbox', { count:20 })
```

### nested values

```javascript
const { pope } = require('pope')
pope('My name is {{profile.name}} and age is {{profile.age}}', { profile: { name:'virk', age: 26 } })
```

### arrays only

```javascript
const { pope } = require('pope')
pope('There are {{0}} emails in your inbox', [20])
```

### prop
Pulls the nested/flat values from an object. It is similar to `lodash.get` method.

```javascript
const { prop } = require('pope')
prop({ count:20 }, 'count') // 20
prop({profile: { name:'virk', age: 26 }}, 'profile.name') // virk
prop([20], '0') // 20
prop({profile: { validate: /^[A-Z][a-z]+/} }, 'profile.validate') //   /^[A-Z][a-z]+/
```

## Options

You can also pass an options object to define the interpolation behavior.

#### skipUndefined
Do not replace the undefined values with an empty string.

```javascript
const { pope } = require('pope')
pope('There are {{0}} emails in your inbox', {}, {
  skipUndefined: true
})
// returns - There are {{0}} emails in your inbox
```

#### throwOnUndefined
Throw exception when a undefined value is found. `throwOnUndefined` gets priority over `skipUndefined` if both are defined.

```javascript
const { pope } = require('pope')
pope('Hello {{ username }}', {}, {
  throwOnUndefined: true
})

// throws exception
```

```js
{
  message: 'Missing value for {{ username }}',
  key: 'username',
  code: 'E_MISSING_KEY',
  stack: '.....'
}
```

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