Components and namespaces


You can import components from a separate file:

#import components

    title: zml
    %for style in page.stylesheets:
      base-style src=style

    %for script in page.scripts:
      script src=script
    base-menu items=pages

The #import statement imports the file components.zml and loads its components. The component statement “base-menu” loads a component “menu” from the “base”-namespace. In this example there is a parameter for the compoment named “items”. The value “pages” is a property of the context, which can be supplied in a controller which calls the render function of the template with a template context or by using a data section.


The file components.zml contains a #namespace statement which set the namespace-alias for the namespace “” to “base”.

The components are defined with a * star symbol followed by the name of the component.


      %for item in items:
        li: {item.title}

  link rel='stylesheet' type='text/css' href='{src}'