jsxmin-express

3.0.0-jsxish • Public • Published

jsxmin-express

jsxmin allows you to write JSX and transpile it to plain, vanilla javascript without React or any other runtime libraries.

This is the Express plugin for jsxmin — please see jsxmin for additional context.

Installation

npm install jsxmin-express

Usage

See the express example folder for more details server.js

// NOTE: "borrowed" from:
// https://expressjs.com/en/starter/hello-world.html

const express = require('express');
const app = express();

app.set('view engine', 'jsxmin-express')

app.get('/', (req, res) => {
  res.render('home', {
    time: new Date()
  });
});

app.listen(3000, () => {
  console.log(`Example app listening at http://localhost:3000`);
});

views/home.jsx

// global template (could import this from a common directory, for example)
const Layout = props => <html><body>{props.children}</body></html>;

module.exports = props => <Layout>
  The time is currently: {props.time}
</Layout>

Options

doctype[='<!DOCTYPE html>']

Prepended to the beginning of the response when handling an html response.

License

MIT

Package Sidebar

Install

npm i jsxmin-express

Weekly Downloads

4

Version

3.0.0-jsxish

License

MIT

Unpacked Size

3.38 kB

Total Files

3

Last publish

Collaborators

  • mattpowell