API Reference

Box.Pattern Class

Description

The pattern object of the Box class.
This module parses the string and tests if the string matches the pattern.

You can use a regular expression, a function or a Backbone-like string in the rule param.

Constructor

Box.Pattern

(rule)

The pattern object of the Box class.
This module parses the string and tests if the string matches the pattern.

You can use a regular expression, a function or a Backbone-like string in the rule param.

Parameters

Methods

match

(str) Object

Tests if the string matches the pattern and returns the parameters in the URL. Returns null if the string doesn’t matches the pattern.

For example:

// posts/:id
pattern.match('posts/89')
// {0: 'posts/89', 1: '89', id: '89'}
// posts/*path
pattern.match('posts/2013/hello-world')
// {0: 'posts/2013/hello-world', 1: '2013/hello-world', path: '2013/hello-world'}

Parameters

Returns

test

(str) Boolean

Tests if the string matches the pattern.

Parameters

Returns