Routes are defined by using ~ as a prefix. The routes will be used by a dispatcher and linkto components.

#import components
#inherit base

  list: '/blog/posts'
  show: '/blog/post/{id}'
  edit: '/blog/post/{id}/edit'

      base-linkto action='list': List
      base-linkto action='show' id=1: Details
      base-linkto action='edit' id=1: Edit

The rendered result:

<!DOCTYPE html>
      <li><a href="/blog/posts">List</a></li>
      <li><a href="/blog/post/1">Details</a></li>
      <li><a href="/blog/post/1/edit">Edit</a></li>

The linkto-component of the base namespace is simply defined:


  a href=_path(action, _params):

The _path function is a core function of the zml implementation. It will return an url path by interpolating the parameters into the route path definition. The routevars wrapped by moustaches in the route-section (~) with the corresponding action name will be replaced by the values of the second function parameter of the _path function.

The _params context property contains all parameters of a component. F.e. the following line will use the linkto-component with the parameters action and id. The component can access the parameters by using the _params context property. The linkto-component will forward the _params property as a parameter of the _path function.

base-linkto action='edit' id=1