lua-resty-template for VS Code
Syntax highlighting, snippets, and language support for lua-resty-template .tpl files.
Features
- Syntax highlighting for all template tags with embedded Lua and HTML support
- Real-time diagnostics — inline error hints for:
- Unclosed template delimiters (
{% without %}, {{ without }}, etc.)
- Unclosed brackets in content regions (missing
}, ], ) in JSON/HTML between template tags)
- Unclosed named blocks (
{-name-} without matching closing tag)
- Unclosed Lua control structures (
if/end, for/do/end, repeat/until, etc.) across {% %} blocks
- Auto-closing pairs for template delimiters (
{{, {%, {#, etc.)
- Comment toggling with
{# #} block comments (Cmd+/ / Ctrl+/)
- Code folding for Lua control structures and HTML tags
- Bracket matching for all template delimiter pairs
- 20 snippets for common template patterns
| Tag |
Description |
Snippet prefix |
{{expression}} |
HTML-escaped output |
rto |
{*expression*} |
Raw/unescaped output |
rtraw |
{% code %} |
Lua code block |
rtcode |
{(template)} |
Include template |
rtinc |
{(file, {ctx})} |
Include with context |
rtincctx |
{[expression]} |
Dynamic include |
rtexp |
{# comment #} |
Template comment |
rtcomment |
{-name-}...{-name-} |
Named block |
rtblock |
{-verbatim-}...{-verbatim-} |
Verbatim (no processing) |
rtverbatim |
{-raw-}...{-raw-} |
Raw (no processing) |
rtrawblock |
Snippets
All snippets are prefixed with rt:
rtfor - For loop (ipairs)
rtforp - For loop (pairs)
rtforn - Numeric for loop
rtif - If block
rtife - If-else block
rtifee - If-elseif-else block
rtblock - Named content block
rtlayout - Layout template boilerplate
rtview - View template with block
rtlocal - Local variable declaration
rtcond - Inline conditional output
Installation
From VS Code Marketplace
Search for lua-resty-template in the Extensions panel (Ctrl+Shift+X).
From VSIX
- Download the
.vsix file from Releases
- In VS Code: Extensions >
... menu > Install from VSIX
From Source
- Clone this repository
pnpm install
- Open in VS Code and press F5 to launch the Extension Development Host
| |