Centiloc Service Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Create DPP Template

Use enrolui to create your dpp templates.

  • Having an account with editor rights at least.

1. Create DPP Template

In order to create a template you need to fill in the following information:

  • Display Name: this is the name used to identify easily a template in the system. Display names must be unique.
  • Content: this is the content of the template, its structure.

1

2. Variables

A variable is a reference inside the DPP template that is replaced with real data when the DPP is generated.

Variables follow a hierarchical structure that indicates where the data comes from and what type of data it represents.

For instance: {{ .product.name }} can become Shampoo Hydratant.

Variables allow the same template to automatically generate a passport for any item.

2.1. Structure

A variable describes where the information comes from.

Its structure is: {{ .source.type.field }}.

Example: {{ .product.labels.sku }}.
This means:

  • product: the data comes from the product.
  • labels: the value is stored in product labels.
  • sku: the value is stored in the sku product label.

field is optional for direct attributes.

It is required when using:

  • labels
  • components

2.1.1. Supported sources

Currently there are two sources available:

Source Description Supported type
dpp DPP-level information. Direct attributes
item Item-level information. Direct attributes and labels
product Product-level information. Direct attributes, labels, medias and components

2.1.2. Supported data types

Currently there are four types supported:

  • Direct attribute: basic product or item information.
    Example:

    {{ .product.name }}
    {{ .item.uid }}
    
  • Labels: custom fields attached to product or item.
    Example:

    {{ .product.labels.sku }}
    {{ .item.labels.lot }}
    
  • Medias (product only): product DPP medias stored as list.
    Example:

    {{ .product.medias }}
    
  • Components (product only): structured lists of elements attached to product.

    • Components are composed of:
      • name
      • labels

    Example:

    {{ range .product.components.allergens }}
        - **{{ .name }}** | {{ .labels.percentage }}
    {{ end }}
    
Because components and medias are lists, they must be used with the range keyword.

2.2. Conditional rendering

Templates can include logic to display content only when data exists.

This keyword must be placed before the placeholder: {{ KEYWORD .placeholder }}.

Each keyword must be closed by an {{ end }} statement.

For more information please check the go template userguide.

2.2.1. range keyword

The range keyword allows you to iterate over lists, typically components.

Example:

{{ range .product.components.allergens }}
- **{{ .name }}**
{{ end }}

This will display the name of each component in the category allergens.

Because medias do not have any field, they must be accessed with {{ . }} in the block.

Example:

{{ range .product.medias }}
    {{ . }}
{{ end }}

2.2.2. Context inheritance

When using conditional rendering, nested placeholders automatically refer to the current element.

Example:

{{ range .product.components.allergens }}
- **{{ .name }}**
{{ end }}

In this example: {{ .name }} refers to the name of the current allergen.

This allows templates to remain short and easy to read.

2.3. Direct attributes list

Below is a list of direct attributes available for placeholders:

Source Direct attribute Placeholder Description
dpp name {{ .dpp.name }} the product reference
dpp NAME {{ .dpp.NAME }} the product reference in uppercase
product name {{ .product.name }} the product reference
product NAME {{ .product.NAME }} the product reference in uppercase
product description {{ .product.description }} the product description
product img {{ .product.img }} the product favorite dpp media
product url {{ .product.url }} the product url
product model3D {{ .product.model3D }} the product favorite dpp media
product dimensions {{ .product.dimensions }} the product favorite dpp media
item uid {{ .item.uid }} the item UID
item UID {{ .item.UID }} the item UID in uppercase
item url {{ .item.url }} the product favorite dpp media

2.4. Specific variables

It exists some specific variable:

  • {{ .company }}: displays the tenant name.
  • {{ .COMPANY }}: displays the tenant name in uppercase.