add-template

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Add Template

添加模板

Always use the skill
load-plain-reference
to retrieve the ***plain syntax rules — but only if you haven't done so yet.
Templates use Liquid syntax (
{% include %}
) to reuse the same spec content across multiple
.plain
files. Each inclusion can pass different parameters, producing tailored output from a single source. This is distinct from
import
and
requires
— templates are about textual reuse with parameterization, not module dependencies.
请务必使用技能
load-plain-reference
来获取***plain语法规则——但仅在你尚未获取的情况下使用。
模板使用Liquid语法(
{% include %}
)在多个.plain文件中复用相同的规格内容。每次引入都可以传递不同的参数,从单一源生成定制化的输出。这与
import
requires
不同——模板侧重于带参数化的文本复用,而非模块依赖。

When to Use Templates

何时使用模板

  • The exact same spec structure is needed in more than one
    .plain
    file.
  • The reused content differs only in specific values (names, paths, config) that can be parameterized.
  • You want a single source of truth for a pattern that appears in multiple modules.
  • 多个.plain文件需要完全相同的规格结构时。
  • 复用内容仅在特定值(名称、路径、配置)上存在差异,且这些值可参数化时。
  • 你希望为出现在多个模块中的模式提供单一事实来源时。

Format

格式

Including a Template

引入模板

Use
{% include %}
with the template path and parameters:
plain
{% include "console_app_template.plain", main_file_name: "app.py", app_name: "MyApp" %}
Parameters are passed as key-value pairs after the template path. Inside the template, parameters are accessed using Liquid variable syntax (
{{ main_file_name }}
).
使用
{% include %}
并指定模板路径和参数:
plain
{% include "console_app_template.plain", main_file_name: "app.py", app_name: "MyApp" %}
参数以键值对形式传递在模板路径之后。在模板内部,使用Liquid变量语法(
{{ main_file_name }}
)访问参数。

Writing a Template

编写模板

Templates live in the
template/
directory. Only variables (
{{ variable_name }}
) are supported — conditionals, loops, and other Liquid features are not available:
plain
***definitions***
- :{{ app_name }}MainFile: is the entry point file for :{{ app_name }}:.

***implementation reqs***
- :{{ app_name }}MainFile: should be called "{{ main_file_name }}".
模板存储在
template/
目录中。仅支持变量
{{ variable_name }}
)——不支持条件语句、循环及其他Liquid功能:
plain
***definitions***
- :{{ app_name }}MainFile: is the entry point file for :{{ app_name }}:.

***implementation reqs***
- :{{ app_name }}MainFile: should be called "{{ main_file_name }}".

Workflow: Including an Existing Template

工作流程:引入现有模板

  1. Check the
    template/
    directory
    to see what templates are available.
  2. Read the template to understand what parameters it expects and what content it produces.
  3. Add the
    {% include %}
    statement
    to the target
    .plain
    file with the correct parameters.
  4. Verify that the expanded content does not introduce concept name collisions or duplicate sections.
  1. 检查
    template/
    目录
    ,查看可用的模板。
  2. 阅读模板,了解它所需的参数以及生成的内容。
  3. 添加
    {% include %}
    语句
    到目标.plain文件中,并传入正确的参数。
  4. 验证展开后的内容不会导致概念名称冲突或重复章节。

Workflow: Creating a New Template

工作流程:创建新模板

  1. Identify the repeated pattern — find spec content that is duplicated (or will be duplicated) across multiple
    .plain
    files.
  2. Extract the common content into a new
    .plain
    file in the
    template/
    directory.
  3. Parameterize the differences — replace the varying parts with Liquid variables.
  4. Update the original files to use
    {% include %}
    instead of the duplicated content.
  1. 识别重复模式——找出在多个.plain文件中重复(或将要重复)的规格内容。
  2. 提取通用内容
    template/
    目录下的新.plain文件中。
  3. 参数化差异部分——将变化的部分替换为Liquid变量。
  4. 更新原始文件,使用
    {% include %}
    替代重复的内容。

Validation Checklist

验证检查清单

  • Template file is in the
    template/
    directory
  • All varying parts are parameterized with Liquid variables
  • All required parameters are passed at each
    {% include %}
    call site
  • Expanded content does not introduce concept name collisions
  • Template is used by more than one
    .plain
    file (otherwise, inline the content)
  • 模板文件位于
    template/
    目录中
  • 所有变化部分均使用Liquid变量进行参数化
  • 在每个
    {% include %}
    调用位置都传入了所有必要的参数
  • 展开后的内容不会导致概念名称冲突
  • 模板被多个.plain文件使用(否则,直接将内容内联即可)