# ttfl

> Tag your templates but defer the choice of tag function until a later date.

Latest version **1.1.0** (published 2021-02-09) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-02-09 |
| First published | 2021-02-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^14.5.0 |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paul Kiddle |
| Maintainers | paulkiddle |
| Keywords | tag, template, for, later, tagged, function, defer, tagging, method, function |

## Links

- npm: https://www.npmjs.com/package/ttfl
- Repository: https://gitlab.com/paulkiddle/ttfl
- Homepage: https://gitlab.com/paulkiddle/ttfl#readme
- Issues: https://gitlab.com/paulkiddle/ttfl/issues
- npm.io page: https://npm.io/package/ttfl

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-02-09
- 1.0.0 — 2021-02-04

## README

# Template Tag For Later

Tag your templates but defer the choice of tag function until a later date.

Great for library authors who want to allow consumers to select their own tag functions.

```javascript
// horses.js
import html from 'ttfl';

const template = html`<marquee>${'I <3 horses, best of all the animals'}</marquee>`;

export default template;
```

```javascript
import html from 'escape-html-template-tag';
import horseTemplate from './horses.js';

console.log(html(horseTemplate).toString());
```

You can also nest the templates for extra fun:

```javascript
import sql from 'ttfl';

const s1 = sql`SELECT author_id, count(*) as total FROM books GROUP BY author_id`;
const s2 = sql`SELECT * FROM (${s1}) AS books LEFT JOIN authors ON(authors.id=books.author_id);`

import sqlTag from 'sql-template-tag';

export default s2(sqlTag);
```

## Members

<dl>
<dt><a href="#ttfl">ttfl</a> ⇒ <code><a href="#tagged">tagged</a></code></dt>
<dd><p>Tag a template for later.
Returns a function that you can pass the real tag function to.
If any of the template values are ttfl functions, the tag will be applied to them too.
You can also call ttfl as a regular function - in which case nested ttfls will not be altered.</p>
</dd>
</dl>

## Functions

<dl>
<dt><a href="#join">join(parts, joiner)</a> ⇒ <code><a href="#tagged">tagged</a></code></dt>
<dd><p>Join an array of parts into a single value</p>
</dd>
</dl>

## Typedefs

<dl>
<dt><a href="#tagged">tagged</a> : <code>function</code></dt>
<dd><p>A tagged template callback, ready to be used</p>
</dd>
</dl>

<a name="ttfl"></a>

## ttfl ⇒ [<code>tagged</code>](#tagged)
Tag a template for later.
Returns a function that you can pass the real tag function to.
If any of the template values are ttfl functions, the tag will be applied to them too.
You can also call ttfl as a regular function - in which case nested ttfls will not be altered.



| Param | Type | Description |
| --- | --- | --- |
| lits | <code>String</code> | Template literal |
| ...values | <code>any</code> | Tempalte values |

<a name="join"></a>

## join(parts, joiner) ⇒ [<code>tagged</code>](#tagged)
Join an array of parts into a single value



| Param | Type | Description |
| --- | --- | --- |
| parts | <code>Array</code> | Parts to join together |
| joiner | <code>\*</code> | Value to use to join the parts together |

<a name="tagged"></a>

## tagged : <code>function</code>
A tagged template callback, ready to be used



| Param | Type | Description |
| --- | --- | --- |
| tag | <code>function</code> | A template tagging function to pass the saved template to. |

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