@js-npm/exports
v0.1.2
Published
Easy data exports to your client-side scripts.
Downloads
8
Readme
exports
Description
Easy data exports to your client-side scripts for your express based app.
Synopsis
const express = require('express');
const exports = require('exports');
const app = express.createServer();
app.dynamicHelpers({
include_exports: exports.helper('App') // App is the namespace.
});
exports.set('title', 'I am awesome.'); // Global export.
app.get('/', [exports.middleware], function(req, res) {
res.exports.random = Math.random(); // Export per request.
res.rend('index');
});
layout.jade:
!!!
html
head
!= include_exports
body!= body
Result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
const App = {"title": "I am awesome.", "random": 0.27449309756048024};
</script>
</head>
<body></body>
</html>
Requirements
- NPM (http://npmjs.org/)
- Node.js 12.0 (http://nodejs.org/)
Install
npm install @js-npm/exports
Tests
npm install
make test
License
Apache License
Copyright (c) 2020 Alex [email protected]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.