baklib-theme-dev
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBaklib 模板开发
Baklib Template Development
Baklib 站点前台使用 Liquid 模板(与 Shopify 模板体系相近)。模板作者通过 对象(变量)、指令(控制逻辑,官方称 Tag)、过滤器(转换输出)组合页面。
Baklib's site frontend uses Liquid templates (similar to Shopify's template system). Template authors build pages by combining objects (variables), directives (control logic, officially called Tags), and filters (transform output).
术语
Terminology
| 术语 | 含义 |
|---|---|
| 对象 | 在 |
| 指令 | 在 |
| 过滤器 | 在 |
| Term | Definition |
|---|---|
| Object | Variables or properties output in |
| Directive | Control flow in |
| Filter | Connected with |
工作流(按需阅读)
Workflow (Read as Needed)
| 场景 | 文档 |
|---|---|
在产品仓库中新建 | create-theme-scaffold.md |
| 复刻参考网站(分析、适配、分期落地、质检;多步须先确认) | website-cloning-workflow.md |
| Scenario | Document |
|---|---|
Create | create-theme-scaffold.md |
| Clone Reference Website (analysis, adaptation, phased implementation, quality inspection; multiple steps require prior confirmation) | website-cloning-workflow.md |
文档索引(references/
)
references/Document Index (references/
)
references/按需打开下列文件获取完整表格与示例:
| 文件 | 内容 |
|---|---|
| directory-and-naming.md | 主题目录、 |
| liquid-tags.md | 页面模板与布局中的自定义指令、 |
| shared-snippets-source.md | |
| objects-and-drops.md | 全局变量、按场景传入的变量、 |
| filters.md | 产品提供的自定义过滤器(含站点扩展) |
| limits-and-security.md | 主题名规则、分页上限、 |
| seeds-and-migrations.md | |
Open the following files as needed for complete tables and examples:
| File | Content |
|---|---|
| directory-and-naming.md | Theme directory, naming conventions for |
| liquid-tags.md | Custom directives in page templates and layouts, |
| shared-snippets-source.md | The three built-in snippets in |
| objects-and-drops.md | Global variables, scenario-specific variables, and objects like |
| filters.md | Custom filters provided by the product (including site extensions) |
| limits-and-security.md | Theme name rules, pagination limits, |
| seeds-and-migrations.md | |
能力边界
Scope
- 说明对象:面向在 Baklib 站点主题中编写 Liquid 的开发者;不描述 Baklib 应用后台或 Rails 实现细节。
- 与标准 Liquid 的关系:除下列自定义能力外,可使用 Liquid 标准语法与内置过滤器。
- 版本差异:具体站点是否开启登录、搜索、反馈、AI 等功能以租户配置为准;模板中应对空值做判断(如 )。
{% if current_user %}
- Target Audience: For developers writing Liquid for Baklib site themes; does not cover details of Baklib's application backend or Rails implementation.
- Relationship with Standard Liquid: Except for the following custom capabilities, you can use standard Liquid syntax and built-in filters.
- Version Differences: Whether functions like login, search, feedback, and AI are enabled for a specific site depends on tenant configuration; templates should handle null values (e.g., ).
{% if current_user %}
快速示例
Quick Example
liquid
{% layout "theme" %}
<h1>{{ site.name }}</h1>
{% for p in site.pages | limit: 5 %}
<a href="{{ p.path }}">{{ p.link_text }}</a>
{% endfor %}liquid
{% layout "theme" %}
<h1>{{ site.name }}</h1>
{% for p in site.pages | limit: 5 %}
<a href="{{ p.path }}">{{ p.link_text }}</a>
{% endfor %}