haxe-sublime-bundle icon indicating copy to clipboard operation
haxe-sublime-bundle copied to clipboard

haxe-react JSX highlighting support

Open zabojad opened this issue 8 years ago • 2 comments

Hi there !

How hard would that be to add support for the JSX highlighting with the excellent haxe-react library?

Basically, I think a first (and possibly easy) way to do this would be to apply XML syntax highlighting to anything within a jsx('...') call.

Event better would be to override it with haxe syntax highlighting for everything within { ... } within jsx(' ... ').

Here is a JSX snippet example:

package ;
import api.react.ReactComponent;
import api.react.ReactMacro.jsx;

class Example extends ReactComponentOf<Dynamic, Dynamic, Dynamic> {

    function touchCb(index : Int) {
        trace('touched $index');
    }

    function renderButton(index : Int) {

        return jsx('
            <div>
                <button onTouchTap={function(){ touchCb(index);  }}>TOUCH ME</button>
            </div>
        ');
    }

    override function render() {

        return jsx('
            <div className="myComp">
                <div className="blabla">
                <p>blablabla</p>
                </div>
                { [ for(i in 0...5) renderButton(i) ] }
            </div>
        ');
    }
}

zabojad avatar Jun 03 '16 13:06 zabojad

It's not really trivial: I don't think XML syntax would be compatible with JSX, first (because of attributes, mainly), so you should probably test this first. Maybe we could have a look at how existing react plugins solve this (https://github.com/facebookarchive/sublime-react).

clemos avatar Jun 13 '16 14:06 clemos

JSX is basically pure XML code with haxe code embedded within curly braces... Nothing else. This would definitively be enough for a first round.

Can you give the big picture of how to add a syntax support to the haxe sublime text plugin?

zabojad avatar Jun 13 '16 19:06 zabojad