Tera & MiniJinja Studio
Editor support for the template engines of Rust web projects: Tera (.tera; Rocket, Zola and others, Tera 2 and Tera 1) and MiniJinja, the engine of Laravel…
Install in
Editor support for the template engines of Rust web projects: Tera
(.tera; Rocket, Zola and others, Tera 2 and Tera 1) and MiniJinja,
the engine of Laravel for Rust views.
Template modes
- Each template is handled as Tera or as MiniJinja, detected per file; the two are kept apart, so a MiniJinja view never gets Tera's built-ins or checks, and a Tera template never gets MiniJinja's
- Laravel for Rust views (
resources/**/*.htmlof a crate that depends onlaravel-rust) open as templates without any file type setting - Laravel's template helpers (
vite,route,csrf_field,old,error,attributes, …), MiniJinja's filters, tests and tags (call,with,from … import), functions registered withadd_function, view names such aslayouts.app, and the data handlers pass toview(..): completion, hover, go to definition and checks
Rust-aware
- Variables, fields and types come from the Rust code that renders the template (any render function,
generic page shells,
#[serde(flatten)], Rocket's formContext); layouts and partials inherit them - Functions, filters and tests registered from Rust, with documentation and go to definition
- Open a template from the Rust string that names it; complete template paths while typing in Rust; template
roots from
Rocket.toml,Tera::new,relative!,set_current_diror a setting - Variables of data without Rust types can be described in a JSON Schema file
Tera 2 and Tera 1
- The version is detected per template; built-ins, tags and checks follow it
- Components, typed parameters and type checks; migration from Tera 1 to Tera 2 for a file or a project
Editing
- Highlighting with HTML, CSS and JavaScript inside templates; whitespace control; clear syntax errors
- Completion and hover for variables, filters, tests, macros and components
- Comment, brace matching, auto-closing delimiters, folding, live templates, Reformat Code
- Loop, loop-else and join quick fixes for a list or map printed as it is
Navigation and refactoring
- Go to definition, blocks along the
extendschain, usages of components with the line and file - Find Usages and Rename for blocks, macros, variables, components and template files (Rust strings follow)
- Template errors in the Run window are links to the template
為 Rust 網站的模板引擎提供編輯支援:Tera(.tera,支援 Tera 2 與 Tera 1)
與 MiniJinja(Laravel for Rust 的 view)。
- 模板模式:每個模板依檔案判定為 Tera 或 MiniJinja,兩者互相隔離;Laravel for Rust 的 view 自動以模板開啟,提供
Laravel 輔助函式(
vite、route、csrf_field、old……)、MiniJinja 的 filter/test/標籤、add_function註冊的函式、layouts.app形式的 view 名稱與 handler 傳入的資料 - Rust 感知:變數、欄位與型別來自渲染模板的 Rust 程式碼;自訂 function/filter/test;從 Rust 字串開啟模板; 模板根目錄可自動偵測或手動設定;沒有 Rust 型別的資料可用 JSON Schema 描述
- Tera 2 與 Tera 1:依模板偵測版本;元件、型別檢查;可從 Tera 1 遷移到 Tera 2
- 編輯:語法上色(內含 HTML/CSS/JavaScript)、補全與懸停文件、註解、括號配對、自動補全、摺疊、Live Template、 Reformat Code;直接輸出清單或 map 時提供迴圈與 join 的快速修正
- 導覽與重構:跳到定義、沿
extends鏈的 block 導覽、元件使用處(顯示行內容與檔案)、 Find Usages 與 Rename(含模板檔案與 Rust 字串)、Run 視窗的錯誤連結
Written by Joobi from the project's own listing. See the source page
1.4.0
The plugin is now Tera & MiniJinja Studio (formerly Tera Template Studio): it adds MiniJinja, the engine of Laravel for Rust views.
- Template modes: each template is handled as Tera or as MiniJinja, detected per file. The two are kept apart: Tera templates work exactly as before.
- Laravel for Rust views (
resources/**/*.htmlof alaravel-rustcrate) open as templates with no setup. - Laravel's helpers (
vite,route,csrf_field,old,error,attributes, …), MiniJinja's filters, tests and tags, and functions registered withadd_function: completion, hover and go to definition. - View names such as
layouts.appresolve, complete and are checked; the data handlers pass toview(..)is completed.
Settings → Languages & Frameworks → Tera → Template mode can force either engine.
外掛更名為 Tera & MiniJinja Studio(原 Tera Template Studio),新增 Laravel for Rust 所用的 MiniJinja 引擎。
- 模板模式:每個模板依檔案判定為 Tera 或 MiniJinja,兩者互相隔離,Tera 模板的行為完全不變。
- Laravel for Rust 的 view(
laravel-rustcrate 的resources/**/*.html)不需設定即以模板開啟。 - Laravel 輔助函式、MiniJinja 的 filter/test/標籤、
add_function註冊的函式:補全、懸停說明、跳到定義。 layouts.app形式的 view 名稱可解析、補全與檢查;handler 傳給view(..)的資料可補全。
可在 Settings → Languages & Frameworks → Tera → Template mode 強制使用其中一種引擎。
1.3.1
- Zola sites: components defined in
.htmltemplates are found, no more "Unknown component". - Zola functions and filters (
get_url,get_section,markdown, …) are known, anddateorstriptagsare no longer reported as removed. - Zola variables:
page,section,termandconfighave completion, hover and typo warnings.
Register *.html under Settings → Editor → File Types → Tera Template to use it in a Zola site.
- Zola 網站:找得到
.html模板裡定義的元件,不再顯示「Unknown component」。 - Zola 函式與 filter(
get_url、get_section、markdown……)可辨識,date、striptags不再被標為已移除。 - Zola 變數:
page、section、term、config有補全、懸停說明與拼字警告。
在 Zola 網站使用請到 Settings → Editor → File Types → Tera Template 加入 *.html。
Follow this listing's changes (Atom feed)