Skip to main content

API References

parsed#

This is the default export. We use to create the parsed tag helper method. Return a function that accepts a tagged template literal and turns it into a pathname.

v1: https://tsei.jp/api/v1
v2: https://tsei.jp/api/v2

Adapting based on props#

You can pass a function to a parsed path's template literal to adapt it based on its props. When setting the next prop to true, we are switching its version number.

Api: api/v1
Get: api/v2/get

Extending parses#

To easily make a new pathname that inherits from another paths. Here we use the api url from the last section and create a special one.

Api: http://tsei.jp/api
Dev: http://tsei.jp/api

Parsing any pathname#

The parsed method works perfectly on all of your own or any third-party pathname.

Api: //
Api: /port:3001;root:http://;

Attaching additional props#

To avoid unnecessary wrappers that just pass on some props to the path, you can use the .withAttrs constructor. It allows you to attach additional props to a path.

Furthermore you can also attach more dynamic props to a component. The .withAttrs object also takes functions, that receive the props that the path receives. The return value will be merged into the resulting props as well.

Here we render an root path and attach some dynamic and static attributes to it:

This allows each wrapper to override nested uses of .withAttrs. Root's .attrs are applied first, and then Api's .attrs:

Api: tsei.jpapi/v1
Dev: tsei.jpapi/v1
Pro: tsei.jpapi/v1