frontly
v1.0.1
Published
Create dynamic web pages with ease
Downloads
4
Readme
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:
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!