Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable knockout.js-specific code highlighting in phpstorm/webstorm

I am trying to enable knockout.js-specific code highlighting in phpstorm using language injections. So far I was able to do so in data-bind XML attributes, which was pretty straightforward:

Language Injection Settings window

But I can't figure out how to create an injection for knockout-style comments <!-- ko: --> <!-- /ko -->

There is a generic xml injection in php storm, but I don't know what to put in the 'Places patterns' section:

Places patterns settings

like image 414
Vovcheg Avatar asked Aug 10 '15 19:08

Vovcheg


1 Answers

It's not possible without a WebStorm/PHPStorm plugin.

<!-- ko if: someExpressionGoesHere -->
    <li>I want to make this item present/absent dynamically</li>
<!-- /ko -->

Is one style of comment, you would need to set up language injection for the DSL (Domain Specific Language) of the knockout templating style, as well as getting it to handle the javascript inside the comment.

Since the 'if:' DSL inside the comment, doesn't register as a HTML attribute (It's wholly ignored as a comment), Doesn't match the attribute format, and that the feature doesn't have support for having comments have meaningful semantics, we are screwed.

like image 54
Ryan Leach Avatar answered Sep 29 '22 07:09

Ryan Leach