HTML Template language where the majority of the language is XML

I'm new to plugin development so I'm looking for some advice on the direction I need to take in order to build a template language for HTML that is also XML based, but has a few expressions that need to have another language injected as well.

The language is ISML (http://en.wikipedia.org/wiki/InterShop_Markup_Language), which for the most part could be written as an extension of HTML.  There are additional tags such as:  <isloop> <isif> <isifelse> <isset> etc...

There is a tag that contains an embedded language <isscript>  Inside this tag will be a Demandware Script langauge.
There is also a comment tag <iscomment> That marks a comment.

The only other part of the language is an expression ${} that can contain Demanware Script as well for comparision, displaying a variable, etc...

To start I just want to get autocompletion working for the extended tags with their attributes and let the parser know that when it is inside <isscript> or <iscomment> that there is another language there or a comment.

So my question is, do I just extend the HTML language or do I need to write a template language from scratch.  I'd rather not reimplement the HTML language and just add what I need to it.  How would one get started on something like this.

Thanks,
Charlie

4 comments

As far as I understand, the only way you could have support for your scripting language inside ${} is by writing a full template language implementation. (Note that it's not quite as scary as it sounds, and doesn't require you to reimplement HTML. The main thing you need to do is write a lexer that distinguishes between an outer language and the inner one.)

If you can live without that, you can use XmlElementDescriptorProvider and related APIs to add support for your custom tags, and use language injection to inject your scripting language into <isscript>.

0

Thanks Dmitry!  I'm going to continue reading the basic tutorials to build the SimplePlugin, then I'm going to look more into how to build the inner language and use the html as the outer language.  I found this thread and was wondering if it is a good example of how to do this or do you have any good examples of how to do this?  I'm really new to plugin development and also haven't done a ton of lexing/parsing so any documentation/code examples would be a huge help.

Also just to clarify about using XmlElementDescriptorProvider instead of creating a full template language.  Would I still be able to syntax highlight ${} and not the expressions inside of ${} characters?  I don't necessarily need to auto complete or syntax highlight the language inside those expressions at this point, treating them as strings for now would be acceptable, but if there is an equal ammount of work to use XmlElementDescriptorProvider instead of writing a full on custom language then I would prefer to go that route, that is if I can figure it out :D  If the effort was low enough to get started, it might be okay to use XmlElementDescriptorProvider and replace with a custom language later on when I want to add more features.

Just to give you a little back story about why I would like to do this, there is a company called Demandware that uses an eclipse plugin that provides template support for these languages, remote debugging on their servers and webdav on file save to remote development environments, plus some other things.  I really dislike Eclispe, especially for writing html, css, JavaScript, basically anything that has to do with front end languages (well actually I dislike it for basically everything) and I greatly miss being able to use Intellij for my day to day duties since we started using Demandware.  I'm hoping that I can provide enough support for the things they offer in Eclipse that I can eventually switch back because it doesn't look like my company is going to get off of their platform any time soon.

So thank you for the help with this, I greatly appreciate it.

-Charlie

0

I also try to write a plugin which supports ISML. I managed to get syntax highlighting working.

But mixing in HTML causes problems. The SingleRootFileViewProvider reports: "refused to parse text with Language: HTML; languages: [Language: ISML]; base: Language: ISML".

The ISMLFileViewProvider just handles ISML. The file extension is ISML, so I think I can not use the AnguarJS plugin as an example, because here the Angular elements are embedded in HTML.

How can I change my file view provider so that it also handles HTML?

0

Sorry to bring this thread back up, but I'm getting closer to my goal of supporting an isml language and I want to clear up a few things before I head down the wrong path.

To support isml so far I have simply extended html using the XmlElementDescriptorProvider as you helpfully mentioned. I'm not sure this is the right approach though because ISML can be embedded anywhere as it is the template language. It can also be used to write anything a template could write and has it's own extension isml, but for the most part it's used to construct html. Because of this sometimes the ISML is inside of the HTML like JSP, (Actually I think ISML is basically like JSP without a namespace on the tags.) For example <div <isif condition="${}"></isif>></div>

There are also isml expressions that I've mentioned before inside ${} or inside an <isscript>

So my question is, for this purpose, if I were to do this the right way, how would I build this up.

isml as the base and html and the ${} as template languages?

html as the base with isml and ${} as the template languages?

Can you have multiple template languages?

0

Please sign in to leave a comment.