Enable JavaScript templates
Turn on the JavaScript Templates gate so Eta template documents and `js` frontmatter entries run on this device.
JavaScript 模板 is a per-device gate that lets JavaScript run inside your templates. It is disabled by default.
In ZotLit 2.1 the language lived in the file name: zotlit-note.eta.md was an
Eta template and zotlit-note.liquid.md was a Liquid one. A 2.2 template
document declares its language in its own manifest instead, with the key
language: eta.
A managed frontmatter entry declares its language with its value member: expr
(Liquid), value (JSON-e), or js (JavaScript). See
Profile document for the manifest
keys and the three entry members.
What the gate covers
- Eta template documents. A profile document, a citation text, or a partial whose manifest sets
language: eta. jsfrontmatter entries. A managed frontmatter entry whose value member isjs.
The expr and value members stay active whether the gate is on or off. While
the gate is off, an Eta document is never compiled and a js entry never
evaluates.
Understand the implications first
Eta templates run JavaScript with the same access as ZotLit itself: they can read and modify your vault, connect to the internet, and on desktop, access your system. Read JavaScript templates for the full explanation before opting in.
Turn on
Open the template engine settings
In Obsidian, open Settings > ZotLit > 高级. Locate the 模板引擎 group and its JavaScript 模板 row.
Click Turn on
Click the 打开 button. A confirmation modal titled 启用 JavaScript 模板吗? appears with the following warning:
Eta 模板运行 JavaScript,具有与 ZotLit 本身相同的访问权限:它们可以读取和修改您的仓库、连接到互联网以及在桌面上访问您的系统。仅当您信任仓库中的每个模板文件时才启用此功能。
Click 启用 to confirm.
The gate takes effect immediately. ZotLit recompiles the template folder in place. No plugin reload is needed.
Turn off
In the same JavaScript 模板 group, click 关闭. The gate disables immediately with no confirmation modal. Every template document that declares language: eta becomes inert, and every managed frontmatter entry declared with js stops evaluating until you turn the gate back on.
Per-device scope
The setting is stored locally on the device, outside the synced plugin data. Enabling it on one device does not enable it on another. Each device where you want Eta documents and js entries to run requires its own opt-in.
See also
JavaScript templates
What the gate enables, risks, and behavior when disabled.
Profile document
The manifest keys, the note source, and the Annotation Section.
Customize a template
Edit a template document and switch its language to Eta.
How templates work
The three template document kinds, their filenames, and the two languages.
Last updated on