Pyramid Syntax for Mustermann
This gem implements the pyramid
pattern type for Mustermann. It is compatible with Pyramid and Pylons.
Overview
Supported options:
capture
, except
, greedy
, space_matches_plus
, uri_decode
and ignore_unknown_options
External Documentation: Pylons Framework: URL Configuration, Pylons Book: Routes in Detail, Pyramid: Route Pattern Syntax
require 'mustermann/pyramid'
Mustermann.new('/{prefix}/*suffix', type: :pyramid).params('/a/b/c') # => { prefix: 'a', suffix: ['b', 'c'] }
pattern = Mustermann.new('/{name}', type: :pyramid)
pattern.respond_to? :expand # => true
pattern.(name: 'foo') # => '/foo'
pattern.respond_to? :to_templates # => true
pattern.to_templates # => ['/{name}']
Syntax
Syntax Element | Description |
---|---|
{name} | Captures anything but a forward slash in a semi-greedy fashion. Capture is named name. Capture behavior can be modified with capture and greedy option. |
{name:regexp} | Captures anything matching the regexp regular expression. Capture is named name. Capture behavior can be modified with capture. |
*name | Captures anything in a non-greedy fashion. Capture is named name. |
/ | Matches forward slash. Does not match URI encoded version of forward slash. |
any other character | Matches exactly that character or a URI encoded version of it. |