schwartzman

0.9.2 • Public • Published

schwartzman

Webpack loader for Mustache. Compiles jsx.mustache files to ReactJS.

in-browser demo

why?!

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

installation

$ npm install --save-dev schwartzman

And add to your webpack.config.js

  • {test: /\.jsx\.mustache$/, loader: "schwartzman"} to module.loaders
    • ⚠️ if you use partials, you'll need to "wrap" this loader with babel-loader or any other dependency solving loader

      {test: /\.jsx\.mustache$/, loader: "babel-loader!schwartzman"}

  • ".jsx.mustache" to resolve.extensions
module.exports = {
  entry: {
    // ...
  },
  output: {
    // ...
  },
  module: {
    loaders: [
      // ...
      {test: /\.jsx\.mustache$/, loader: "schwartzman"},
    ],
  },
  resolve: {
    extensions: [
      // ...
      ".jsx.mustache",
    ],
    // ...
  }
  // ...
}

supported mustache blocks (with some limitations for attributes):

  • {{ variable }} and {{{ escaped_variables }}}
  • {{# section }}
  • {{^ inverted_section }}
  • {{! comment }}
  • {{> partial }}

development

$ npm i
$ npm test

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.9.211latest
0.2.00@0.2.0
0.1.30@0.1.3

Version History

VersionDownloads (Last 7 Days)Published
0.9.211
0.9.10
0.9.00
0.8.00
0.7.6295
0.7.50
0.7.40
0.7.30
0.7.20
0.7.10
0.7.00
0.6.00
0.5.00
0.4.00
0.3.10
0.3.00
0.2.10
0.2.0-a0
0.2.00
0.1.30
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i schwartzman

Weekly Downloads

5

Version

0.9.2

License

MIT

Unpacked Size

75.6 kB

Total Files

4

Last publish

Collaborators

  • zemlanin