How to Add Variables to Your DocMiral Templates (Complete Guide for Creators)

Creating powerful templates in DocMiral is not just about design. The real magic happens when your template becomes dynamic — able to accept data, adapt to users, and generate documents automatically.

To make this possible, DocMiral templates support three types of variables. Each serves a different purpose and gives you a different level of control.

In this guide, you will learn when and how to use:

  • MiniApp Fields
  • Type Defined Fields
  • Generic Fields

You do not need to understand backend data structures or schemas. Everything here focuses on what matters to template creators: writing templates effectively.


The Big Picture

Think of template variables as three levels of intelligence:

Variable TypeBest ForUI SupportComplexity
MiniApp FieldsStructured sectionsDedicated UIAdvanced
Type Defined FieldsSingle controlled inputsBuilt-in field UIMedium
Generic FieldsFlexible API dataNo UI requiredSimple

Choose the one that matches how structured your data needs to be.


1. MiniApp Fields (Structured Sections)

MiniApps are the most powerful type of variable.

They connect your template to a dedicated editing interface designed for a specific document section.

Instead of manually defining many fields, you reference a ready-made data editor.

When to Use MiniApps

Use MiniApps when:

  • A section has multiple related fields
  • Users need a guided UI
  • Data may repeat (lists)
  • The structure is reusable across templates

Typical examples:

  • Resume personal details
  • Work experiences
  • Education history
  • Invoice items
  • Inspection reports

Accessing MiniApp Data

MiniApp fields use the mini() directive.


Object Example

{{ mini(name='resumes/personal', key='name') }}

This pulls a single value from the Resume Personal MiniApp.

Example output:

John Doe

List Example

MiniApps can also return lists.

{% for item in mini(
name="resumes/experiences",
items=["title", "company", "date_start", "date_end"]
) %}

Inside the loop:

{{ item.title }}
{{ item.company }}
{{ item.date_start }}
{{ item.date_end }}

This automatically renders multiple experience entries added by the user.


Why MiniApps Are Powerful

You get:

  • Structured editing UI
  • Consistent data format
  • Cleaner templates
  • Reusable sections across templates

Instead of designing inputs yourself, you reuse intelligent components.


2. Type Defined Fields (Smart Inputs)

Sometimes you only need one field, not a full MiniApp.

That’s where Type Defined Fields come in.

They allow you to declare a field and specify how it should behave.


Using the text() Directive

Example:

{{ text(
name='agreement_text',
title='Agreement Text',
type='smarteditor'
) }}

This creates:

  • A named variable
  • A labeled input
  • A specific editor type

When to Use Type Defined Fields

Use them for:

  • Agreements
  • Descriptions
  • Notes
  • Custom paragraphs
  • Checkboxes
  • Dates
  • Dropdown selections

Essentially, any single configurable input.


Benefits

  • No UI coding required
  • Consistent input behavior
  • Cleaner creator experience
  • Controlled data format

You define intent, DocMiral handles the interface.


3. Generic Fields (Pure Template Variables)

Generic fields are the simplest and most flexible option.

They use standard Jinja-style variables.

Perfect for:

  • API users
  • Automation workflows
  • Fully custom data sources

Simple Variables

{{ name }}

or nested:

{{ client.name }}

Lists

{% for item in items %}
{{ item }}
{% endfor %}

Complex Example

{% set result = data.report_info.inspection_result|lower %}
<span class="
{% if result == 'pass' %} bg-green-600
{% elif result == 'hold' %} bg-yellow-500
{% elif result == 'fail' %} bg-red-600
{% else %} bg-gray-500
{% endif %}
">
{{ data.report_info.inspection_result }}
</span>

This allows full logic control inside templates.


When to Use Generic Fields

Choose generic fields when:

  • Data comes from APIs
  • You want maximum flexibility
  • No built-in UI is required
  • You already control the data structure

They are especially popular among developers integrating DocMiral programmatically.


Choosing the Right Variable Type

A simple rule:

Use MiniApps when structure matters.

Example: Resume experiences.


Use Type Defined Fields when input matters.

Example: Agreement text or comments.


Use Generic Fields when flexibility matters.

Example: API-generated inspection results.


Decision Guide

SituationRecommended Type
Resume sectionMiniApp
Long editable paragraphType Defined
API data renderingGeneric
Repeating structured entriesMiniApp
One configurable inputType Defined
Dynamic logic-heavy layoutGeneric

Mixing Variable Types (Best Practice)

A professional template often combines all three.

Example resume template:

  • Personal info → MiniApp
  • Summary text → Type Defined field
  • API metadata → Generic fields

This layered approach gives both usability and flexibility.


Creator Tips

Keep templates readable

Group related variables together.

Prefer MiniApps for reusable sections

They reduce duplication across templates.

Use Generic fields for advanced logic

They give you full control when needed.

Name fields clearly

Good naming improves usability later.


Final Thoughts

DocMiral templates are designed to scale from simple documents to complex automated systems.

By understanding these three variable types, you can build templates that are:

  • Easier for users to fill
  • More reusable
  • API-friendly
  • Future-proof

Start simple, then progressively enhance your templates using MiniApps and typed fields as your document grows.

Comments

One response to “How to Add Variables to Your DocMiral Templates (Complete Guide for Creators)”

Leave a Reply

Your email address will not be published. Required fields are marked *