Path Helpers

nti.nikola_chameleon provides some helpers for use in path expressions. These are implemented either as path adapters, which use a namespace:name syntax, or as views, which use @@view_name syntax. Both of these methods leverage the component architecture.

This document will mention each path helper provided, and where appropriate, direct you to more information.

Post Helpers

These helpers are applied to any IPost object.

Formatted Date

The post object has a formatted_date method that produces a string representing a date, and which requires one parameter, the name of the date format. There is a standard format called webiso, and the user-configured date format is at options/date_format.

The formatted_date path adapter lets us call this function easily in a path expression.

Type Python Expression Path Expression
Constant python:post.formatted_date('webiso') post/formatted_date:webiso
Variable python:post.formatted_date(options['date_format']) post/formatted_date:?date_format


Posts have a method called meta that returns metadata. It takes a string argument naming what metadata to return. Although these are almost always used in templates in a static way, it is possible that the metadata might be a variable.

The meta path adapter lets us call this function easily in a path expression.

Type Python Expression Path Expression
Constant python:post.meta('type') post/meta:type
Variable python:post.meta(options['meta']) post/meta:?meta

Post Text

The text method on a post can take an optional parameter telling it to truncate to a teaser length. This is configurable by the user for index pages, but repeatedly accessing the configuration is tedious. The post_text view provides helpers to automatically take this into account for indexes. It also helps when embedding posts into other pages.

Typical example:

<tal:block tal:repeat="post context/posts">
  <article tal:define="post_text post/@@post_text"
           class="h-entry post-${post/meta:type}
      <div class="p-${post_text/content_kind}
          The content of the post.

          This may be just a teaser.

Generic Views

These view objects are registered as default views for any object. You can override that registration for something more specific if needed.


The feeds view provides helpers for producing RSS and Atom links in the header of pages. See the methods defined there for more information.

Typical usage:

<tal:block xmlns:tal=""
           tal:define="kind options/kind|nothing;
                       feeds context/@@feeds">
  ${structure:python:feeds.feed_translations_head(kind=kind , feeds=False)}


The post_css has helpers to produce CSS, typically based on the kind of page being rendered.

Typical usage:

<article metal:fill-slot="content"
             tal:define="post context"
             class="post-${context/meta:type} h-entry hentry
             itemscope="itemscope" itemtype="">


See also

Using Macros

The macros view provides an alternative to the macro: expression type. It is used when you wish to look up a macro having a different context than the current context. The object you traverse through to reach the @@macros view becomes the context used to find and execute the macro. This is most helpful when dealing with a list of posts.

Typical usage:

<div tal:repeat="post context/posts">
  <p metal:use-macro="post/@@macros/comment_link"
     class="commentline" />