0.2.1 • Published 6 years ago

@mjstahl/jtml v0.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

jtml

Templating engine using JavaScript's tagged template literals.

Installation

$ npm install --save @mjstahl/jtml

Usage

Express

After installing the jtml package, we set the location of the views and the engine Express will use to render those views.

  app.set('views', './views')
  app.set('view engine', 'jtml')

Next create a file named index.jtml in the ./views directory with the following content:

<html>
  <head>
    <title>${title}</title>
  </head>
  <body>
    <h1>${message}</h1>
  </body>
</html>

Now we can configure a route that will render the index.jtml file.

  app.get('/', (req, res) => {
    res.render('index', {
      title: 'Your first JTML template',
      message: 'Looking good!'
    })
  })