@sryden/lightning

1.0.1 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i @sryden/lightning

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

6.88 kB

Total Files

3

Last publish

Collaborators

  • halex