> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Nextedy RISKSHEET uses Velocity templates to customize the user interface, PDF export output, and cell rendering behavior.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

<Columns cols={3}>
  <Card title="Velocity Templates" icon="file" href="/risksheet/reference/templates/velocity-templates">
    Core Velocity template syntax, available context variables, macro definitions, and best practices for all Risksheet template types.
  </Card>

  <Card title="Top Panel Template" icon="file" href="/risksheet/reference/templates/top-panel-template">
    Customize the panel above the Risksheet grid with buttons, filters, summary statistics, risk profile displays, and interactive controls using Velocity and HTML.
  </Card>

  <Card title="PDF Export Template" icon="file" href="/risksheet/reference/templates/pdf-export-template">
    Configure PDF export layout, page structure, table formatting, and content rendering using the `risksheetPdfExport.vm` Velocity template and export helper macros.
  </Card>

  <Card title="Custom Renderer Templates" icon="file" href="/risksheet/reference/templates/custom-renderers">
    Build custom cell renderers and row header renderers using client-side JavaScript functions (registered from the top panel template) for specialized data display and conditional visual formatting.
  </Card>
</Columns>

## Template Resolution Flow

Templates follow the same inheritance chain as the sheet configuration. When Risksheet loads a template (such as `risksheetPdfExport.vm` for PDF export), it searches for the file in this order:

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/yWl5nA2D0IzEnZC1/risksheet/diagrams/reference/templates/index/diagram-1.svg?fit=max&auto=format&n=yWl5nA2D0IzEnZC1&q=85&s=c72323d67ab4510d3be3372040d94516" alt="diagram" style={{ maxWidth: "480px", width: "100%" }} width="480" height="370" data-path="risksheet/diagrams/reference/templates/index/diagram-1.svg" />
</Frame>

This resolution order means a document-level attachment always takes precedence over inherited templates. If no template is found at any level, Risksheet uses its built-in default behavior.

<Tip title="Override vs. Inherit">
  To create a document-specific template that overrides the inherited default, use **Menu > Override Template** in the Risksheet interface. This detaches the document configuration from the global template and creates local copies of all configuration files, including Velocity templates. You can revert back to template inheritance later, but reverting discards any document-specific customizations.
</Tip>

## Template Types Summary

| Template File                 | Purpose                             | Server Endpoint              | Rendering Engine      |
| ----------------------------- | ----------------------------------- | ---------------------------- | --------------------- |
| `risksheetPdfExport.vm`       | PDF export script generation        | `/api/pdfscript`             | Velocity + JavaScript |
| Top panel Velocity template   | Custom UI panel above the grid      | `/api/panel`                 | Velocity + HTML       |
| `pdfExportMacros.vm`          | Shared helper macros for PDF export | Included by PDF template     | Velocity              |
| `serverRender` column scripts | Per-column custom cell rendering    | Per-column configuration     | Velocity              |
| Row header renderer           | Custom row header display           | `headers.rowHeader.renderer` | JavaScript function   |

## Template Context Access

All Velocity templates have access to a rich context that includes:

| Context Variable        | Description                                                                                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Document object         | Current Polarion LiveDoc document with metadata                                                                                                                     |
| Transaction             | Active Polarion transaction for data operations                                                                                                                     |
| Polarion services       | Server-side API for querying work items and project data                                                                                                            |
| Velocity tools          | Standard Velocity utility classes for formatting and logic                                                                                                          |
| Risksheet configuration | Current sheet configuration settings including columns, levels, and dataTypes (enum and rating scales come from Polarion enumerations, not the sheet configuration) |
| Revision parameter      | Document revision for historical views (PDF export)                                                                                                                 |

<Note title="Error Handling">
  If a Velocity template contains syntax errors or references unavailable context variables, Risksheet renders the error as a red message box in place of the expected output. Check the Polarion server logs for detailed template rendering errors.
</Note>

## Related Reference

* [Risksheet.json Format](/risksheet/reference/configuration/risksheet-json-format) for the main sheet configuration structure that templates extend
* [Template Path Configuration](/risksheet/reference/configuration/template-path-configuration) for configuring document creation paths and template folder settings
* [Document Configuration Override](/risksheet/reference/configuration/document-config-override) for the override workflow that creates document-specific templates
* [Velocity Template Context](/risksheet/reference/api/velocity-context) for the full list of available context variables in Velocity templates
* [PDF Export API](/risksheet/reference/api/pdf-export-api) for the programmatic PDF export interface and export functions available to templates

<LastReviewed date="2026-06-24" />
