CrustyCheese
CrustyCheese

Reputation: 49

Rythm Engine plugin for IntelliJ

I'm writing an IntelliJ plugin, which should recognize rythm engine code in .html files. Rythm is a template engine an the syntax starts with @

I've already done the custom language plugin tutorial from the JetBrains doc.

So far I got Syntax Highlighting partially working for rythm. If I would copy and paste the code below in a .rythm file everything would be well recognized. But then HTML wouldn't be recognized.

I tried the language injection from the IntelliLang plugin but now it recognizes the rythm code only between HTML tags.

In this example @i18n and @something would be recognized as rythm. But @rythmCode is still unhighlighted.

Any ideas how I can get it working even if @rythmCode is outside of HTML tags?

@rythmCode {
<li>
<a href="/xxx">@i18n("xxx")</a>
</li>
<li>
<a href="/xxx/@something.getSomething()">@something.getSomething():@something.getSomething()</a>
</li>
}

@rythmCode() {
<div class="row">
<div class="col-md-6 word-wrap">
    @something.getSomething(): @something.getSomething()
    </div>
<div class="col-md-6 align-right">`

edit:

Finally it works. Now I want to implement a formatter. How can I implement a HTML formatter for the HTML part and a Rythm formatter for the Rythm part?

edit 2: HTML formatter works. Now I need a bit help with the Rythm Formatting. I think something is wrong with my .bnf file.

Upvotes: 0

Views: 356

Answers (1)

Sascha B
Sascha B

Reputation: 680

As we also missed Rythm template engine support in IntelliJ we worked on a plugin which now supports:

  • syntax highlighting
  • brace matcher
  • code completion for basic rythm keywords (e.g. @import, ...)
  • and HTML formatting (autoformatting in IntelliJ will no longer destroy templates)

Its not jet available in the Jetbrains plugin repo (but will be in the near future) but you can just download the jar and install the plugin from disk.

Also its open source: Rythm Engine Detector R.E.D GitHub

Upvotes: 3

Related Questions