1.2.0 • Published 2 years ago

babel-plugin-jsx-inject-mi2 v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

babel-plugin-jsx-inject-mi2 CircleCI

Babel plugin to inject JSX or HTML from external file.

Combined with babel-plugin-jsx-mi2 and (babel-plugin-translate-mi2 / babel-plugin-jsx-translate)

Usage

Used with babel by adding plugin to .babelrc

{
    plugins: ["jsx-inject-mi2"]
}

The plugin replaces occurrence of an return <template/> statement with JSX from external file.

If you jou have a file sample.js with:

//...
    function myFunc(h){
        return <template/>
    }
//...

and template file sample.tpl in the same folder

<div>
    <h1>Title</h1>
    <p>{state.text}</p>
</div>

the sample.tpl will be injected in the sample.js resulting in something like this

//...
    function myFunc(h){
        return <div>
            <h1>Title</h1>
            <p>{state.text}</p>
        </div>
    }
//...

arrow expression

it is good to know that for purpose of catching a return statement, an arrow expression like:

applyHtml( h=><template/> );

is pretty much the same (except of arrow expression scoping) as:

applyHtml( function(h){ return <template/>;} );
1.2.0

2 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago