
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
component-render
Advanced tools
Render html file from template file for component
With Component previously installed:
$ npm install -g component-render
Usage: component-render [options] <template>
Options:
-V, --version
-h, --help output usage information
-l, --local <json> local <json> file
-o, --out <path> output html file <path>
-u, --use <name> use the given render <name> plugin
# redner html file from template file
$ component render simple.jade
# render html file from template file with local json file
$ component render -l user.json user.jade
# render html file to output path
$ component render -o ./static/html/simple.html simple.jade
# render html file with plugin
$ component render -u component-render-hogan -l user.json user.mustache
Use Jade
template engine. Hogan
, EJS
, and other template engine, you can support with plugin.
You need to implement below function.
template
, program
and fn
arugments.template
: a template file path.program
: commander
object.fn
: a callback function. specify error
, html
to arguments.
var hogan = require('hogan.js');
var path = require('path');
var fs = require('fs');
module.exports = function (template, program, fn) {
var local = {};
if (program.local) {
var resolve_path = path.resolve(program.local);
local = fs.existsSync(resolve_path) ? require(resolve_path) : require(resolve_path + '.json');
}
fs.readFile(template, { encoding: 'utf8' }, function (err, data) {
if (err) { return fn(err); }
var renderer = hogan.compile(data);
var html = renderer.render(local);
fn(null, html);
});
};
See the LICENSE
.
FAQs
Render html files from template files for component
The npm package component-render receives a total of 1 weekly downloads. As such, component-render popularity was classified as not popular.
We found that component-render demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.