Frappe Syntax Jinja logo

Frappe Syntax Jinja

Organization
Impertio-Studio
frappe-syntax-jinja

Use when writing Jinja templates for ERPNext/Frappe Print Formats, Email Templates, and Portal Pages. Covers template syntax, context variables, filters, macros, and v16 Chrome PDF rendering. Prevents common mistakes with doc context and child table iteration. Keywords: Jinja, print format, email template, portal page, template syntax, PDF, v14-v16, template syntax, Jinja example, print format code, how to show child table in print.

Overview

PublisherImpertio-Studio
RepositoryFrappe_Claude_Skill_Package
Skill namefrappe-syntax-jinja
Stars
180
Forks
53
Bundled files
10
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 10 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Impertio-Studio on GitHub. Read the source before you install it.

Installation

Install the Frappe Syntax Jinja AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package.git /tmp/Frappe_Claude_Skill_Package
mkdir -p .claude/skills
cp -r /tmp/Frappe_Claude_Skill_Package/skills/source/syntax/frappe-syntax-jinja .claude/skills/frappe-syntax-jinja
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Frappe Syntax Jinja in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Frappe Syntax Jinja on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Frappe Syntax Jinja is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Frappe Jinja Templates Syntax

Deterministic Jinja reference for Print Formats, Email Templates, Notification Templates, and Portal Pages in Frappe v14/v15/v16.


When to Use This Skill

USE when:

  • Creating or modifying Print Formats (Jinja-based)
  • Writing Email Templates with dynamic fields
  • Building Portal Pages (www/*.html) with Python controllers
  • Writing Notification Templates (system/email/SMS)
  • Registering custom Jinja methods or filters via hooks.py

DO NOT USE for:

  • Report Print Formats — they use JavaScript templating ({%= %}), NOT Jinja
  • Client Scripts — see frappe-syntax-clientscripts
  • Server Scripts — see frappe-syntax-serverscripts

Decision Tree: Which Template Type?

Need a printable document?
├─ YES → Is it for a Query/Script Report?
│        ├─ YES → Use JS Template ({%= %}), NOT Jinja
│        └─ NO  → Use Jinja Print Format
└─ NO  → Is it for email?
         ├─ YES → Is it triggered by workflow/notification?
         │        ├─ YES → Notification Template (Jinja)
         │        └─ NO  → Email Template (Jinja)
         └─ NO  → Is it a web page?
                  ├─ YES → Portal Page (www/*.html + .py controller)
                  └─ NO  → frappe.render_template() for ad-hoc rendering

Quick Reference: Jinja Syntax

SyntaxPurposeExample
{{ }}Output expression{{ doc.name }}
{% %}Control statement{% if doc.status == "Paid" %}
{# #}Comment{# This is a comment #}
{{ _("text") }}Translation{{ _("Invoice") }}
{{ val | filter }}Filter{{ name | default("N/A") }}

CRITICAL: Jinja vs JS Template Syntax

AspectJinja (Print Formats)JS Template (Report Print Formats)
Output{{ expression }}{%= expression %}
Code block{% statement %}{% js_code %}
LanguagePythonJavaScript
Contextdoc, frappedata, filters

NEVER use Jinja syntax in Report Print Formats. NEVER use {%= %} in standard Print Formats.


Context Objects by Template Type

Print Formats

ObjectDescription
docThe document being printed (full Document object)
frappeFrappe module (whitelisted methods only)
frappe.utilsUtility functions
_()Translation function
doc.items, doc.taxesChild table accessors (by fieldname)

Email Templates

ObjectDescription
docThe linked document (when triggered from a DocType)
frappeFrappe module (limited)
_()Translation function

Notification Templates

ObjectDescription
docThe document that triggered the notification
frappeFrappe module
_()Translation function

Portal Pages (www/*.html)

ObjectDescription
frappeFrappe module
frappe.session.userCurrent authenticated user
frappe.form_dictQuery parameters from URL
frappe.langCurrent language code
Custom contextSet via get_context(context) in .py controller

Full details: references/context-objects.md


Essential Methods (Whitelisted in Jinja)

Formatting: ALWAYS Use for Display

jinja
{# ALWAYS use get_formatted() for fields in Print Formats #}
{{ doc.get_formatted("posting_date") }}
{{ doc.get_formatted("grand_total") }}

{# Child table rows — ALWAYS pass parent doc for currency context #}
{% for row in doc.items %}
    {{ row.get_formatted("rate", doc) }}
    {{ row.get_formatted("amount", doc) }}
{% endfor %}

{# General formatting with explicit fieldtype #}
{{ frappe.format(value, {'fieldtype': 'Currency'}) }}
{{ frappe.format_date(doc.posting_date) }}

Document Retrieval

jinja
{# Full document — use only when multiple fields needed #}
{% set customer = frappe.get_doc("Customer", doc.customer) %}

{# Single field — ALWAYS prefer over get_doc for one field #}
{% set abbr = frappe.db.get_value("Company", doc.company, "abbr") %}

{# List of records (no permission check) #}
{% set tasks = frappe.get_all("Task",
    filters={"status": "Open"},
    fields=["title", "due_date"],
    order_by="due_date asc",
    page_length=10) %}

{# List with permission check (portal pages) #}
{% set orders = frappe.get_list("Sales Order",
    filters={"customer": doc.customer},
    fields=["name", "grand_total"]) %}

Translation: REQUIRED for All User-Facing Strings

jinja
<h1>{{ _("Invoice") }}</h1>
<p>{{ _("Total: {0}").format(doc.get_formatted("grand_total")) }}</p>

System & Session

jinja
{{ frappe.get_url() }}
{{ frappe.get_fullname() }}
{{ frappe.get_fullname(doc.owner) }}
{{ frappe.db.get_single_value("System Settings", "time_zone") }}
{% if frappe.session.user != "Guest" %}...{% endif %}

Full method reference: references/methods-reference.md


Control Structures

Conditionals

jinja
{% if doc.status == "Paid" %}
    <span class="paid">{{ _("Paid") }}</span>
{% elif doc.status == "Overdue" %}
    <span class="overdue">{{ _("Overdue") }}</span>
{% else %}
    <span>{{ doc.status }}</span>
{% endif %}

Loops with Child Tables

jinja
{% for item in doc.items %}
<tr>
    <td>{{ loop.index }}</td>
    <td>{{ item.item_name }}</td>
    <td>{{ item.get_formatted("amount", doc) }}</td>
</tr>
{% else %}
<tr><td colspan="3">{{ _("No items") }}</td></tr>
{% endfor %}

Loop Variables

VariableDescription
loop.index1-indexed position
loop.index00-indexed position
loop.firstTrue on first iteration
loop.lastTrue on last iteration
loop.lengthTotal number of items

Variables

jinja
{% set total = 0 %}
{% set name = doc.customer_name | default("Unknown") %}

Filters

FilterExampleNotes
default{{ val | default("N/A") }}ALWAYS use for optional fields
length{{ items | length }}Count items
join{{ names | join(", ") }}Join list to string
truncate{{ text | truncate(100) }}Truncate with ellipsis
escape{{ input | escape }}HTML-escape (default behavior)
safe{{ html | safe }}Render raw HTML — NEVER for user input
round{{ num | round(2) }}Round number
lower / upper{{ text | upper }}Case conversion

Full filter reference: references/filters-reference.md


Custom Jinja Methods & Filters via hooks.py

hooks.py Registration

python
# hooks.py
jenv = {
    "methods": [
        "myapp.jinja.methods"       # Module with callable functions
    ],
    "filters": [
        "myapp.jinja.filters"       # Module with filter functions
    ]
}

Custom Method

python
# myapp/jinja/methods.py
import frappe

def get_company_logo(company):
    """Returns company logo URL. Called as get_company_logo() in Jinja."""
    return frappe.db.get_value("Company", company, "company_logo") or ""
jinja
<img src="{{ get_company_logo(doc.company) }}" alt="Logo">

Custom Filter

python
# myapp/jinja/filters.py
def nl2br(text):
    """Convert newlines to <br> tags. Used as {{ text | nl2br }}."""
    return (text or "").replace("\n", "<br>")
jinja
{{ doc.notes | nl2br | safe }}

Details: references/methods.md


Print Format Patterns

Minimal Print Format Template

jinja
<style>
    .print-header { background: #f5f5f5; padding: 15px; }
    .item-table { width: 100%; border-collapse: collapse; }
    .item-table th, .item-table td { border: 1px solid #ddd; padding: 8px; }
    .text-right { text-align: right; }
</style>

<div class="print-header">
    <h1>{{ doc.select_print_heading or _("Invoice") }}</h1>
    <p>{{ doc.name }} — {{ doc.get_formatted("posting_date") }}</p>
</div>

<table class="item-table">
    <thead>
        <tr>
            <th>#</th>
            <th>{{ _("Item") }}</th>
            <th class="text-right">{{ _("Qty") }}</th>
            <th class="text-right">{{ _("Amount") }}</th>
        </tr>
    </thead>
    <tbody>
        {% for row in doc.items %}
        <tr>
            <td>{{ loop.index }}</td>
            <td>{{ row.item_name }}</td>
            <td class="text-right">{{ row.qty }}</td>
            <td class="text-right">{{ row.get_formatted("amount", doc) }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>

<p><strong>{{ _("Grand Total") }}: {{ doc.get_formatted("grand_total") }}</strong></p>

Page Breaks

css
/* v14/v15 (wkhtmltopdf) */
.page-break { page-break-before: always; }

/* v16 (Chrome PDF) — ALWAYS prefer break-* in v16 */
.page-break { break-before: page; }

Full examples: references/examples.md | Patterns: references/patterns.md


V16: Chrome PDF Rendering

Aspectv14/v15 (wkhtmltopdf)v16 (Chrome)
CSS SupportLimited CSS3Full modern CSS
Flexbox/GridPartialFull support
Page breakspage-break-*break-* preferred
FontsSystem fonts onlyWeb fonts supported

V16 Configuration

json
// site_config.json
{
    "pdf_engine": "chrome",
    "chrome_path": "/usr/bin/chromium"
}

Portal Page Pattern

www/projects/index.html

jinja
{% extends "templates/web.html" %}
{% block title %}{{ _("Projects") }}{% endblock %}

{% block page_content %}
<h1>{{ _("Projects") }}</h1>
{% for project in projects %}
    <h3>{{ project.title }}</h3>
    <p>{{ project.description | default("") | truncate(150) }}</p>
{% else %}
    <p>{{ _("No projects found.") }}</p>
{% endfor %}
{% endblock %}

www/projects/index.py

python
import frappe

def get_context(context):
    context.title = "Projects"
    context.no_cache = True
    context.projects = frappe.get_all("Project",
        filters={"is_public": 1},
        fields=["name", "title", "description"],
        order_by="creation desc")
    return context

Full structure: references/structure.md | Templates: references/templates.md


Critical Rules

ALWAYS

  1. Use _() for ALL user-facing strings
  2. Use get_formatted() for currency, date, and numeric fields
  3. Use default() filter for optional/nullable fields
  4. Pass parent doc to child row get_formatted("field", doc)
  5. Use frappe.db.get_value() when you need only one field
  6. Keep calculations in Python controllers, not Jinja templates

NEVER

  1. Execute database queries inside loops (N+1 problem)
  2. Use | safe on user-supplied input (XSS vulnerability)
  3. Use Jinja syntax in Report Print Formats (they require JS {%= %})
  4. Use frappe.get_doc() when frappe.db.get_value() suffices
  5. Hardcode strings without _() translation wrapper
  6. Disable safe_render without security review

Anti-patterns with fixes: references/anti-patterns.md


Reference Files

FileContents
references/syntax.mdJinja syntax reference (tags, filters, tests, loops)
references/methods.mdCustom Jinja methods/filters via hooks
references/context-objects.mdAvailable objects per template type
references/filters-reference.mdAll standard and custom Frappe filters
references/methods-reference.mdAll frappe.* methods available in Jinja
references/examples.mdComplete Print Format, Email, Portal examples
references/anti-patterns.mdCommon mistakes and correct alternatives
references/templates.mdTemplate structure patterns
references/patterns.mdConditional rendering, loops, child tables
references/structure.mdFile structure for template types

See Also

  • frappe-syntax-hooks — jenv configuration in hooks.py
  • frappe-impl-printformat — Print Format implementation patterns
  • frappe-errors-serverscripts — Server-side error handling

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Frappe Syntax Jinja AI skill do?

Use when writing Jinja templates for ERPNext/Frappe Print Formats, Email Templates, and Portal Pages. Covers template syntax, context variables, filters, macros, and v16 Chrome PDF rendering. Prevents common mistakes with doc context and child table iteration. Keywords: Jinja, print format, email template, portal page, template syntax, PDF, v14-v16, template syntax, Jinja example, print format code, how to show child table in print.

Why use Frappe Syntax Jinja on TypingMind?

Because you install it once and use it with any model. Frappe Syntax Jinja is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Frappe Syntax Jinja in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package/tree/main/skills/source/syntax/frappe-syntax-jinja. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Frappe Syntax Jinja?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Frappe Syntax Jinja?

As many as you like. As long as a model supports skills, you can use Frappe Syntax Jinja with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Frappe Syntax Jinja AI skill free?

Yes. It is published on GitHub by Impertio-Studio under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇