jsx-vanilla-loader
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"version" : "0.0.1", | ||
"version": "0.0.2", | ||
"name": "jsx-vanilla-loader", | ||
@@ -11,4 +11,4 @@ "description": "JSX Vanilla loader for Webpack", | ||
"jsx", | ||
"loader", | ||
"webpack" | ||
"loader", | ||
"webpack" | ||
], | ||
@@ -20,4 +20,4 @@ "author": { | ||
"dependencies": { | ||
"jsx-vanilla" : ">=2.0.5" | ||
} | ||
} | ||
"jsx-vanilla": ">=2.0.5" | ||
} | ||
} |
105
readme.md
@@ -1,88 +0,31 @@ | ||
# JSX Vanilla | ||
# JSX Vanilla loader | ||
JSX is a JavaScript XML/HTML syntax extender, that allows you to render XML/HTML tags inside vanilla JavaScript. Originaly inspired by React.js JSX | ||
JSX Vanilla loader for webpack | ||
# Examples of usage | ||
# Examples of webpack.config.js | ||
Here is some examples of JSX Vanilla usage | ||
## Basic syntax | ||
```javascript | ||
let | ||
a = <p>Hello world!</p>, | ||
b = (<p>Hello world</p>), | ||
c = ( | ||
<div> | ||
<p>Hello world!</p> | ||
</div> | ||
) | ||
; | ||
document.body.appendChild(a); | ||
document.body.appendChild(<p>Hello world!</p>); | ||
``` | ||
## Parameters usage | ||
const path = require('path'); | ||
```javascript | ||
const | ||
text = "Hello world!", | ||
six = 6 | ||
; | ||
module.exports = { | ||
mode: "development", | ||
devtool : 'source-map', | ||
entry: { | ||
main: "./src/main.js" | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, '../js'), | ||
filename: "[name].js" | ||
}, | ||
module : { | ||
rules : [ | ||
{ | ||
test : /\.js?/, | ||
include : path.resolve(__dirname, "src"), | ||
loader : 'jsx-vanilla-loader' | ||
} | ||
] | ||
} | ||
} | ||
function test() { | ||
return text; | ||
} | ||
let | ||
a = <p>{text}</p>, | ||
b = (<p>{(2+2)}</p>), | ||
c = (<p>{text()}</p>), | ||
d = (<p>{(six > 5 ? "True" : "False")}), | ||
e = ( | ||
<p>{(function(){ | ||
return 4 > 2 ? "Four bigger than two" : "Two bigger than four"; | ||
})()}</p> | ||
) | ||
; | ||
``` | ||
## Cycles examples | ||
```javascript | ||
const array = ['First', 'Second', 'Third']; | ||
let | ||
a = ( | ||
<ul class="menu"> | ||
{array.map(item => ( | ||
<li>{item}</li> | ||
)).join('')} | ||
</ul> | ||
), | ||
b = ( | ||
<ul class="menu"> | ||
{array.forEach(item => { | ||
return <li>{item}</li> | ||
})} | ||
</ul> | ||
) | ||
; | ||
``` | ||
## Example of file preprocessing | ||
```javascript | ||
const | ||
JSXVanilla = require('jsx-vanilla'), | ||
fs = require('fs') | ||
; | ||
fs.readFile('pathToInputFile', 'utf8', function(err, contents) { | ||
fs.writeFile('pathToOutputFile', JSXVanilla.preprocess(contents), function(err) { | ||
//other code | ||
}); | ||
}); | ||
``` |
997
31