GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Frapwings/component-render: Render html file from template file for component

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
HISTORY.md
HISTORY.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

component-render

Build Status

Render html file from template file for component

Installation

With Component previously installed:

    $ npm install -g component-render

Usage


  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

Example

    # 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

Template engine

Use Jade template engine. Hogan, EJS, and other template engine, you can support with plugin.

How to create plugin

You need to implement below function.

  • Function have template, program and fn arugments.
  • template: a template file path.
  • program: commander object.
  • fn: a callback function. specify error, html to arguments.

Plugin example

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);
  });
};

License

MIT license.

See the LICENSE.

About

Render html file from template file for component

Resources

Readme
License
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.