Template language (blade) support in custom language

Answered

I am developing a plugin to support MJML (custom components on top of html) and got multiple requests to support e.g. blade templates.

But i cant seem to find any resources on how to realize this. 

The mjml plugin is based on xml and has a catalog of predefined elements and some custom resolvers based on JavaScript-Classes and so on.

 

For the blade support i tried to reuse the logic of the blade plugin (com.jetbrains.php.blade.BladeFileViewProvider) but without success.

I am a bit clueless on how to continue right now. I want to avoid rewriting an entire grammar definition at this point. Is there even a way to do this?

The plugins sources are on GitHub: https://github.com/timo-reymann/intellij-mjml-support.

 

So in a nutshell i want to have a file pattern, lets say *_mjml.blade.php where blade and mjml is detected.  Right now i only have a basic mjml file association in place ignoring the blade-Parts

0
2 comments

You need to implement your own FileViewProvider that extends MultiplePsiFilesPerDocumentFileViewProvider. Also, see this Tutorial: Custom templating language plugin

0

Hi Aleksander,

yes i found this but in my case i have not written a lexer, instead reusing xml with custom XmlTagNameProvider and so on.

So there is no other way?

0

Please sign in to leave a comment.