Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

erpnext-syntax-jinjaerpnext 语法神器

Agent Skill

erpnext-syntax-jinja 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,434

周安装

58

GitHub Stars

87

下载量

450
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:erpnext-syntax-jinja(erpnext 语法神器)
来源仓库:https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package
仓库路径:skills/erpnext-syntax-jinja
安装命令:
npx skills add https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package --skill erpnext-syntax-jinja
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package --skill erpnext-syntax-jinja

简介

规定 Jinja 模板在打印格式、邮件模板和门户页面的合法语法与上下文变量。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 中安全渲染动态内容。
  • 列出各模板类型的上下文对象(如 doc、data)及可用过滤器列表。
  • 使用前需避免直接执行用户输入,防止模板注入攻击或渲染异常。
  • erpnext-syntax-jinja 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

ERPNext Jinja Templates Syntax Skill

Correct Jinja syntax for Print Formats, Email Templates, and Portal Pages in ERPNext/Frappe v14/v15/v16.

When to Use This Skill

USE this skill when:

  • Creating or modifying Print Formats
  • Developing Email Templates
  • Building Portal Pages (www/*.html)
  • Adding custom Jinja filters/methods via hooks

DO NOT USE for:

  • Report Print Formats (they use JavaScript templating, not Jinja)
  • Client Scripts (use erpnext-syntax-clientscripts)
  • Server Scripts (use erpnext-syntax-serverscripts)

Context Objects per Template Type

Print Formats

ObjectDescription
docThe document being printed
frappeFrappe module with utility methods
_()Translation function

Email Templates

ObjectDescription
docThe linked document
frappeFrappe module (limited)

Portal Pages

ObjectDescription
frappe.session.userCurrent user
frappe.form_dictQuery parameters
frappe.langCurrent language
Custom contextVia Python controller
See: references/context-objects.md for complete details.

Essential Methods

Formatting (ALWAYS use)

{# RECOMMENDED for fields in print formats #}
{{ doc.get_formatted("posting_date") }}
{{ doc.get_formatted("grand_total") }}

{# For child table rows - pass parent doc #}
{% for row in doc.items %}
    {{ row.get_formatted("rate", doc) }}
    {{ row.get_formatted("amount", doc) }}
{% endfor %}

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

Document Retrieval

{# Full document #}
{% set customer = frappe.get_doc("Customer", doc.customer) %}

{# Specific field value (more efficient) #}
{% set abbr = frappe.db.get_value("Company", doc.company, "abbr") %}

{# List of records #}
{% set tasks = frappe.get_all('Task',
    filters={'status': 'Open'},
    fields=['title', 'due_date']) %}

Translation (REQUIRED for user-facing strings)

<h1>{{ _("Invoice") }}</h1>
<p>{{ _("Total: {0}").format(doc.grand_total) }}</p>
See: references/methods-reference.md for all methods.

Control Structures

Conditionals

{% if doc.status == "Paid" %}
    <span class="label-success">{{ _("Paid") }}</span>
{% elif doc.status == "Overdue" %}
    <span class="label-danger">{{ _("Overdue") }}</span>
{% else %}
    <span>{{ doc.status }}</span>
{% endif %}

Loops

{% 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.firstTrue on first
loop.lastTrue on last
loop.lengthTotal items

Variables

{% set total = 0 %}
{% set customer_name = doc.customer_name | default('Unknown') %}

Filters

Commonly Used

FilterExample
default`{{value \default('N/A')}}`
length`{{items \length}}`
join`{{names \join(', ')}}`
truncate`{{text \truncate(100)}}`
safe`{{html \safe}}` (trusted content only!)
See: references/filters-reference.md for all filters.

Print Format Template

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

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

<table class="table">
    <thead>
        <tr>
            <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>{{ 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") }}:</strong> {{ doc.get_formatted("grand_total") }}</p>

Email Template

<p>{{ _("Dear") }} {{ doc.customer_name }},</p>

<p>{{ _("Invoice") }} <strong>{{ doc.name }}</strong> {{ _("for") }}
{{ doc.get_formatted("grand_total") }} {{ _("is due.") }}</p>

<p>{{ _("Due Date") }}: {{ frappe.format_date(doc.due_date) }}</p>

{% if doc.items %}
<ul>
{% for item in doc.items %}
    <li>{{ item.item_name }} - {{ item.qty }} x {{ item.get_formatted("rate", doc) }}</li>
{% endfor %}
</ul>
{% endif %}

<p>{{ _("Best regards") }},<br>
{{ frappe.db.get_value("Company", doc.company, "company_name") }}</p>

Portal Page with Controller

www/projects/index.html

{% extends "templates/web.html" %}

{% block title %}{{ _("Projects") }}{% endblock %}

{% block page_content %}
<h1>{{ _("Projects") }}</h1>

{% if frappe.session.user != 'Guest' %}
    <p>{{ _("Welcome") }}, {{ frappe.get_fullname() }}</p>
{% endif %}

{% for project in projects %}
    <div class="project">
        <h3>{{ project.title }}</h3>
        <p>{{ project.description | truncate(150) }}</p>
    </div>
{% else %}
    <p>{{ _("No projects found.") }}</p>
{% endfor %}
{% endblock %}

www/projects/index.py

import frappe

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

Custom Filters/Methods via jenv Hook

hooks.py

jenv = {
    "methods": ["myapp.jinja.methods"],
    "filters": ["myapp.jinja.filters"]
}

myapp/jinja/methods.py

import frappe

def get_company_logo(company):
    """Get company logo URL"""
    return frappe.db.get_value("Company", company, "company_logo") or ""

Usage

<img src="{{ get_company_logo(doc.company) }}">

Critical Rules

✅ ALWAYS

  1. Use _() for all user-facing strings
  2. Use get_formatted() for currency/date fields
  3. Use default values: {{value | default('')}}
  4. Child table rows: row.get_formatted("field", doc)

❌ NEVER

  1. Execute queries in loops (N+1 problem)
  2. Use | safe for user input (XSS risk)
  3. Heavy calculations in templates (do in Python)
  4. Jinja syntax in Report Print Formats (they use JS)

Report Print Formats (NOT Jinja!)

WARNING: Report Print Formats for Query/Script Reports use JavaScript templating.

AspectJinja (Print Formats)JS (Report Print Formats)
Output{{}}{%= %}
Code{% %}{% %}
LanguagePythonJavaScript
<!-- JS Template for Reports -->
{% for(var i=0; i<data.length; i++) { %}
<tr><td>{%= data[i].name %}</td></tr>
{% } %}

Version Compatibility

Featurev14v15
Basic Jinja API
get_formatted()
jenv hook
Portal pages
frappe.utils.format_date with format✅+

V16: Chrome PDF Rendering

Version 16 introduced Chrome-based PDF rendering replacing wkhtmltopdf.

Key Differences

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

CSS Updates for V16

/* v14/v15 */
.page-break { page-break-before: always; }

/* v16 - both work, but break-* is preferred */
.page-break { break-before: page; }

Configuration (V16)

# In site_config.json
{
    "pdf_engine": "chrome",  # or "wkhtmltopdf" for legacy
    "chrome_path": "/usr/bin/chromium"
}

Print Format Compatibility

Most print formats work unchanged. Update if using:

  • Complex CSS layouts (flexbox/grid now fully supported)
  • Custom fonts (web fonts now work)
  • Advanced page break control

Reference Files

FileContents
references/context-objects.mdAvailable objects per template type
references/methods-reference.mdAll frappe.* methods
references/filters-reference.mdStandard and custom filters
references/examples.mdComplete working examples
references/anti-patterns.mdMistakes to avoid

See Also

  • erpnext-syntax-hooks - For jenv configuration in hooks.py
  • erpnext-impl-jinja - For implementation patterns
  • erpnext-errors-serverscripts - For server-side error handling

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.83%
按下载量换算152

Claude

32.35%
按下载量换算146

Cursor

19.31%
按下载量换算87

Gemini CLI

9.7%
按下载量换算44

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills