1.0.14 • Published 12 months ago

@eternalconcert/tmpltr v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Example:

import { App, renderTemplate } from '@eternalconcert/tmpltr';

const app = new App();
// or
const app = new App('localhost', 80);
// port defaults to 3000, host to localhost

// also possible:
app.host = '127.0.0.1';
app.port = 8080;

// route registration:
app.route('/', (_req, _resp) => renderTemplate('templates/index.html', {name: 'Bernd Benutzer'}));

app.route('/test/', () => renderTemplate('templates/test.html'));

// the function app.route takes the (relative) url and a callback function, which should return the response content.

// start the server
app.serve();

Utilities

renderTemplate(templateName, context, request, response);

The context might be undefined if not used, otherwise it must be an object in this form: { key: value } The key can be used in the template and will be replaced by the value.

A template might lool like this: \Index!\ Hallo! Das hier ist der Body! Im Context steht folgender Name: {{ contextVariable key }}

As you can see, the contextVariable is used here.

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago