Template like it's 2010!

TMPLTR provides the ability to render HTML pages server-side and use the full power of JavaScript. It is heavily inspired by Flask and Jinja.

Learning TMPLTR will be no problem if you are familiar with these great pieces of software.

Getting started

Create a file called `server.mjs` and add the following code to it:

    
      // server.mjs
      import { App } from 'src/app.mjs';

      const app = new App();

      app.route('/', () => 'hello, world');

      app.serve();
    
  

Open your browser and navigate to http://localhost:3000

If everything works, you should see something like this:

hello, world

Now create a folder called `templates` next to your server.mjs and in that folder create a file called `index.html`. Add the following code

    
      <!-- index.html -->
      

Your flight number: {{ flightNumber }}

Back in server.mjs, change the content to match this:

    
      // server.mjs
      import { App } from 'src/app.mjs';

      const app = new App();

      app.route('/', () => app.renderTemplate('index.html', { flightNumber: '815' }));

      app.serve();
    
  

Refresh your browser and crush into the world of templating.

Your flight number: 815
Counter: 6