api:render

Version 23.0.9145


api:render


Use the api:render keyword to render templates.

Parameters

  • template: The .rst file to evaluate.
  • templateData: The in-memory template to evaluate.
  • in[put]: A comma-separated list of items to pass to the template.
  • out[put]: The resulting item or feed.
  • to: The attribute to push the result into. You can also save the result by wrapping the api:render statement with a multi-line api:set.
  • onerror: The action to perform when an error is encountered in a template. Set onerror to clear to call and render a template only if there are no exceptions.

Control Attributes

None

Examples

Catch an exception so that the main template can render the rest of the content:

<table border="1">
  <tr>
  <td>
    <api:render template="error.rst">
      <api:catch code="*">
        <a name="caught">
        A problem was encountered with the template
        </a>
      </api:catch>
    </api:render>
    <!-- Ensure that tags are closed -->
  </td>
  </tr>
</table>

Render an in-memory template:

<api:setc attr="a.t" value="this is [name]."/>
<api:set attr="i.name" value="a test" />
<api:set item="r" />
<api:render templateData="[a.t]" in="i" to="r.text" />
[r.text]

See Also