@sryden/lightning
v1.0.1
Published
A web server with variable rendering and import support.
Downloads
2
Readme
SRYDEN Lightning
Lightning is a web server module that supports variable rendering and file imports in HTML templates.
Installation
To install Lightning, run the following command:
npm install @sryden/lightning
Usage
Here is an example that makes use of all of Lightning's features:
- Create the Lightning index file (views/index.ltn)
<!-- views/index.ltn -->
<html>
<head>
<title>:title:</title>
:{ '/header' }:
</head>
<body>
<h1>:content:</h1>
:{ '/footer' }:
</body>
</html>
- Use the imports feature to make your code cleaner
<!-- views/header.ltn -->
<header>
<h2>:headerTitle:</h2>
</header>
<!-- views/footer.ltn -->
<footer>
<p>:footerContent:</p>
</footer>
- Create the main file (app.js)
// app.js
const lightning = require('@sryden/lightning');
let example = "Lightning fast";
let headerTitle = "Header";
let footerContent = "Footer";
// Define routes and middleware
lightning.get('/', './views/index', (req, res) => {
res.locals = { title: 'Lightning fast', content: example };
});
lightning.all('/styles', './public/styles', 'text/css'); // This allows you to serve static files
lightning.listen(3000);