8.0.0 • Published 4 years ago
rosid-handler-node v8.0.0
rosid-handler-node
A function that loads a JS file and transforms it to HTML by executing the exported default function. The export function can either be a asynchronous callback function or a async function returning a Promise.
Install
npm install rosid-handler-node
Usage
API
const handler = require('rosid-handler-node')
handler('index.js').then((data) => {})
handler('index.html').then((data) => {})
Rosid
Add the following object to your rosidfile.json
, rosidfile.js
or routes array. rosid-handler-node
will execute all matching JS files in your source folder and save the output as static HTML.
{
"name" : "Node",
"path" : "[^_]*.{html,js}*",
"handler" : "rosid-handler-node"
}
// index.js
// Works with asynchronous callback functions
export default (next) => next(null, '<h1>Hello World</h1>')
// or async functions
export default async () => await '<h1>Hello World</h1>'
<!-- index.html (output) -->
<h1>Hello World</h1>
Parameters
filePath
{String}
Absolute path to file.
Returns
{Promise<String|Buffer>}
The transformed file content.
8.0.0
4 years ago
7.1.3
5 years ago
7.1.2
6 years ago
7.1.1
6 years ago
7.1.0
6 years ago
7.0.0
6 years ago
6.0.2
6 years ago
6.0.1
7 years ago
6.0.0
7 years ago
5.0.1
7 years ago
5.0.0
7 years ago
4.0.0
7 years ago
3.0.2
7 years ago
3.0.1
7 years ago
3.0.0
7 years ago
3.0.0-beta.0
7 years ago
2.1.0
7 years ago
2.0.1
7 years ago
2.0.0
7 years ago
1.0.0
7 years ago
0.0.1
7 years ago