Webpack loader for Mustache. Compiles jsx.mustache files to ReactJS.
Because "built-in" server-side prerender of react components requires JS VM — JSX allows for pretty complex expressions. On the other hand, every language has library for rendering Mustache templates[citation needed]. Plus, Mustache is very simple and basic. So simple, that it's easier to write a Mustache-to-JS compiler than a JSX parser for Python/Perl/PHP/Pascal/P
$ npm install --save-dev schwartzman
And add to your webpack.config.js
{test: /\.jsx\.mustache$/, loader: "schwartzman"}
tomodule.loaders
-
⚠️ if you use partials, you'll need to "wrap" this loader withbabel-loader
or any other dependency solving loader{test: /\.jsx\.mustache$/, loader: "babel-loader!schwartzman"}
-
".jsx.mustache"
toresolve.extensions
module.exports = {
entry: {
// ...
},
output: {
// ...
},
module: {
loaders: [
// ...
{test: /\.jsx\.mustache$/, loader: "schwartzman"},
],
},
resolve: {
extensions: [
// ...
".jsx.mustache",
],
// ...
}
// ...
}
{{ variable }}
and{{{ escaped_variables }}}
{{# section }}
{{^ inverted_section }}
{{! comment }}
{{> partial }}
$ npm i
$ npm test