1.0.1 • Published 5 months ago

@sryden/lightning v1.0.1

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

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:

  1. 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>
  1. 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>
  1. 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);
1.0.1

5 months ago

1.0.0

5 months ago