PathTemplate

PathTemplate

new PathTemplate(data)

Parameters:
Name Type Description
data String

the of the template

Methods

inspect() → {string}

Renders the path template.

Returns:
Type Description
string

contains const names matched to binding values

match(path) → {Object}

Matches a fully-qualified path template string.

Parameters:
Name Type Description
path String

a fully-qualified path template string

Returns:
Type Description
Object

contains const names matched to binding values

Throws:

if path can't be matched to this template

Type
TypeError

parsePathTemplate() → {Array.<string>}

Parse the path template.

Returns:
Type Description
Array.<string>

return segments of the input path. For example: 'buckets/{hello}'' will give back ['buckets', {hello=*}]

render(bindings) → {String}

Renders a path template using the provided bindings.

Parameters:
Name Type Description
bindings Object

a mapping of const names to binding strings

Returns:
Type Description
String

a rendered representation of the path template

Throws:

if a key is missing, or if a sub-template cannot be parsed

Type
TypeError