Skip to content

fenom-template/fenom-phpstorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fenom PhpStorm Plugin

Syntax highlighting for Fenom templates in JetBrains IDEs (PhpStorm, IntelliJ IDEA Ultimate with PHP plugin).

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
  • Configurable color schemes via Settings → Editor → Color Scheme → Fenom
  • File types: *.fenom, *.tpl, *.fm

Installation

From Disk

  1. Download or build Fenom.jar
  2. Open Settings → Plugins → ⚙️ → Install Plugin from Disk...
  3. Select Fenom.jar
  4. Restart the IDE

Compatibility

Plugin Version IDE Version
1.0.0 PhpStorm 2025.1+

Configuration

File Type Association

By default, the plugin registers for *.fenom and *.fm files. To enable highlighting for *.tpl files:

  1. Settings → Editor → File Types
  2. Find Fenom template in the list
  3. Add *.tpl to the registered patterns

Color Scheme

Customize colors at Settings → Editor → Color Scheme → Fenom. Available elements:

Element Description
Comments {* comment *}
Keywords if, foreach, set, etc.
Variables $variable
Strings 'string', "string"
Numbers 42, 3.14
Operators ??, ?., ~, .., ->, ::
Brackets {, }
Punctuation ., ,, :

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}

Building from Source

Prerequisites

  • JDK 17+
  • JFlex 1.9.1+ (only needed if modifying .flex files)
  • PhpStorm installed (provides the SDK JARs for compilation)

Build

# Set PhpStorm path (optional, defaults to /Applications/PhpStorm.app/Contents on macOS)
export PS_HOME="/Applications/PhpStorm.app/Contents"

# Build the plugin
./build.sh

The output JAR will be at build/Fenom.jar.

Regenerating Lexers

If you modify src/ru/maxisoft/fenom/lexer/FenomTop.flex or FenomSub.flex, regenerate the lexers:

jflex -d src/ru/maxisoft/fenom/lexer/ src/ru/maxisoft/fenom/lexer/FenomTop.flex
jflex -d src/ru/maxisoft/fenom/lexer/ src/ru/maxisoft/fenom/lexer/FenomSub.flex

Do not edit the generated *FlexLexer.java files directly — they are overwritten by JFlex.

Project Structure

├── META-INF/
│   └── plugin.xml              Plugin descriptor
├── src/ru/maxisoft/fenom/
│   ├── FenomLanguage.java       Language registration
│   ├── editor/                  Syntax highlighter & color settings
│   ├── file/                    File type, icons, view provider
│   ├── lexer/                   Two-stage lexer (JFlex)
│   │   ├── FenomTop.flex        Top-level lexer (HTML vs macros)
│   │   ├── FenomSub.flex        Macro body lexer (tokens)
│   │   └── LayeredLexer.java    Wires both lexers together
│   ├── parser/                  PSI parser definition
│   └── psi/                     Token types & PSI elements
├── build.sh                     Build script
└── README.md

License

This project is licensed under the MIT License.

Releasing

Push a version tag to trigger automatic build and GitHub Release creation:

git tag v1.0.0
git push origin v1.0.0

This creates a release with Fenom.jar attached, ready for download.

About

Fenom template engine plugin for PhpStorm / JetBrains IDEs

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors