Some basic conventions of template creation

Calendar 👁️ 1381

Using AnqiCMS templates.htmlAs template file suffix, and stored in/templateIn the template folder, the static resources such as styles, js scripts, images, and so on used by the template are stored separately/public/static/Directory.

The use of template files is similar to the tag syntax of Django template engine, variables are defined using double curly braces, such as{{变量}}. Condition judgment, loop control and other tags are defined using single curly braces and percent signs, and they need to be terminated with an end tag, appearing in pairs, such as{% if archive.Id == 10 %}这是文档ID为10的文档{% endif %}.

Variable names follow camelCase naming convention, with the first letter of each word capitalized, with some exceptions, such as{archive.Id}/{archive.Title}.

The template file should be encoded in UTF8, if it is encoded in other encoding, it will cause the page to display garbled, and it will not display normally. If Windows users edit template files, please save them as template files encoded in UTF-8 format.

The supported types of templates include: adaptive template type, code adaptation template type, PC+mobile end template type.

Templates support separate mobile end template definitions, mobile end templates are stored in.mobileThe directory, when choosing the template for code adaptation mode, PC + mobile end mode, needs to be createdmobileTemplate.

The template supports some default custom names. As long as these custom template files exist, there is no need to set the template separately in the background, and the template can be automatically applied.

The supported template name situations:

  • The default custom template name format of the document is:{模型table}/{文档id}.html
  • The default custom template name format of the document list is:{模型table}/list-{分类id}.html
  • The default custom template name format of the single page is:page/{单页面id}.html

Related articles

Template Creation Directory and Template

The root directory of AnqiCMS template is /template, each template set needs to create its own template directory under /template, and add a config. configuration file in the template directory to specify some information about the template.The content format of the config. file is: { "name": "Default template", "package": "d"}

2022-06-07

Template Tags and Usage

The use of template files is similar to the Django template engine's tag syntax, variables are defined using double curly braces, such as {{variable}}.Conditional statements, loop control tags, etc., are defined using single curly braces and percent signs and must be terminated with an end tag, tags must appear in pairs, such as { if archive.Id == 10 } This is the document with ID 10 { endif }. Within the system.

2022-06-07

Why Editing Templates in External Editors Does Not Take Effect

The template caching mechanism description: Anqi CMS adopts memory caching optimization strategy in the production environment (production): Preloading at startup: The template files are loaded into memory all at once when the service starts Rendering acceleration: The page requests directly read the memory template, avoiding repeated disk I/O operations Performance advantages: Reduce server load, improve web page response speed to milliseconds level Development modification注意事项 When modifying template files through external editors (Baota panel/VSCode, etc.): ✖ Modifications only affect disk files ✖ The memory cache template does not update automatically

2025-08-13