Skip to content

fenom-template/fenom-vscode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fenom VSCode Extension

Syntax highlighting for Fenom template engine in VSCode.

Features

  • Syntax highlighting for Fenom template tags and expressions
  • Support for Fenom 3.x operators: ??, ?., ?->, ~, ~~, ~=, .., ->, ::, ?:
  • Highlighting for keywords: if, else, elseif, foreach, foreachelse, set, var, include, insert, block, extends, parent, as, default, matches, not, and more
  • Variable, string, number, modifier, operator, and comment highlighting
  • Bracket matching and auto-closing
  • Code folding for control structures

Installation

From VSCode Marketplace

Search for "Fenom" in VSCode extensions and install.

From Source

# Clone the repository
git clone https://github.com/maxisoft/fenom-vscode.git
cd fenom-vscode

# Install dependencies (if needed for development)
npm install

# Package the extension
vsce package

# Install from local .vsix
code --install-extension fenom-*.vsix

File Types

The extension recognizes:

  • *.fenom
  • *.fm
  • *.tpl (manual association via VSCode File Associations settings)

Example

{* Template comment *}
<h1>{$title|default:'Hello World'}</h1>

{set $user = $app->getUser()}

{if $user?->name ?? 'Guest'}
    <p>Welcome, {$user?->name}!</p>
    <p>City: {$user?.address?.city}</p>
{elseif $name is not empty}
    <p>Hello {$name ~ '!'}</p>
{else}
    <p>Welcome, stranger!</p>
{/if}

{foreach $items as $item index $i}
    {if $item.published}
        <div>{$i}. {$item.title} — {$item.price ?? 'free'}</div>
    {/if}
{foreachelse}
    <p>No items found.</p>
{/foreach}

{include 'pagination.tpl' pages=$pages}

Architecture

This extension is a port of the IntelliJ IDEA plugin to VSCode.

The syntax highlighting is defined using TextMate grammars (fenom.tmLanguage.json), which are converted from the original JFlex lexer definitions:

  • FenomTop.flex → Top-level grammar (HTML vs macro detection)
  • FenomSub.flex → Macro body grammar (variables, modifiers, operators)

Building

# Install vsce if not already installed
npm install -g vsce

# Package
vsce package

# Publish (requires publisher token)
vsce publish

License

MIT License - see LICENSE file.

About

VSCode extension for Fenom template syntax highlighting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors