# ql.io-uri-template

> A small URI template processor for ql.io.

Latest version **0.8.0** (published 2012-08-16) · 0 weekly downloads

## Install

```sh
npm install ql.io-uri-template
pnpm add ql.io-uri-template
yarn add ql.io-uri-template
bun add ql.io-uri-template
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2012-08-16 |
| First published | 2011-11-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | > 0.8.2 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 927 |
| Author | ql.io |
| Maintainers | s3u, shimonchayim, prabhakhar |

## Links

- npm: https://www.npmjs.com/package/ql.io-uri-template
- Repository: https://github.com/ql-io/ql.io
- npm.io page: https://npm.io/package/ql.io-uri-template

## Recent versions

- 0.8.0 (latest) — 2012-08-16
- 0.7.0 — 2012-07-02
- 0.6.2 — 2012-05-29
- 0.6.1 — 2012-05-23
- 0.6.0 — 2012-05-21
- 0.5.2 — 2012-04-19
- 0.5.1 — 2012-04-19
- 0.5.0 — 2012-03-30
- 0.4.6 — 2012-03-29
- 0.4.5 — 2012-03-28
- 0.4.4 — 2012-03-28
- 0.4.3 — 2012-03-12
- 0.4.2 — 2012-02-16
- 0.4.0 — 2012-02-13
- 0.4.0-beta — 2012-01-17
- … 2 more at https://npm.io/package/ql.io-uri-template/versions

## README

This module provides a small URI template parser. ql.io uses URI templates for specifying URIs of
APIs. See [docs](http://ql.io/docs/uri-template) for more examples.

## Syntax Overview

Here is overview of the syntax.

1. Each template can have an arbitrary number of tokens enclosed in braces (`{` and `}`).

    http://myserver/somepath?p1={v1}&p2={v2}

2. You can generate URIs from URI templates by calling the `format()` function with an object
   containing values, and optionally, default values.

3. All tokens are optional and single valued by default.

4. You can mark that a token is required by prefixing the name of the token with `^`. When the
   value for a required token is missing, formatting will fail.

    http://myserver/somepath?p1={^v1}&p2={v2}

5. You can also mark that a token is multi-valued by prefixing the name of the token with a `|`.

    http://myserver/somepath?p2={|v2}

If the value of `v2` is `['v2_1','v2_2']`, calling the `format()` would result in

    http://myserver/somepath?p2=v2_1,v2_2

Some APIs may not take more than a given number of values. In such cases, you can specify a maximum
integer before `|`.

    http://myserver/somepath?p1={^v1}&p2={5|v2}

If you supply more than 5 values, the `format()` function will return `Math.ceil(n/5)` URIs.

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