1.0.1 • Published 3 years ago

frontly v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Frontly.js

Frontly.js is express middleware that allows you to inject dynamic content into your webpages.

How to use

First, install frontly.

npm install frontly

Second, require it and use it as middleware.

const express = require('express');
const Frontly = require('frontly');

const app = express();
app.use(Frontly.middleware);

Third, make a HTML file that you want to serve.

<!DOCTYPE html>
<html>
  <head>
    <title>Frontly Demo</title>
  </head>
  <body>
    <h1><::Frontly.Custom.Title::></h1> <!-- This is the syntax for Frontly in an HTML document. -->
  </body>
</html>

Finally, serve the file with res.sendFileFrontly().

app.get('/', (req, res) => {
  res.sendFileFrontly(__dirname + '/index.html', {
    params: {
      Title: "Hello, world!"
    }
  });
});

Here's the final product:

image

Run on replit

Syntax

To escape normal HTML and use dynamic Frontly content, open it up with <:: and close with ::>, putting whatever Frontly reference you would like in between. For example, you could do: <::Frontly.Version::>, which uses the built in Frontly.Version reference. To use a custom reference, use Frontly.Custom.*.

Documentation

Full docs are coming soon, but it's spring break and it's kind of late so I'll see you next week!