Skip to content

YodaLightsabr/Frontly.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Frontly

  • middleware

    • Use as express middleware

res

  • sendFrontly

    • file: The text you want to send
    • options: Options for sending the file
    • options.params: The custom Frontly parameters to pass
    • Similar to req.send(), but you can pass Frontly parameters
  • sendFileFrontly

    • file: The file you want to send
    • options: Options for sending the file
    • options.params: The custom Frontly parameters to pass
    • Similar to req.sendFile(), but you can pass Frontly parameters

About

Create dynamic webpages with ease

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published