0.0.2 • Published 10 years ago

html-factory v0.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
10 years ago

html-factory

It is a tool that replicates the HTML from excel and HTML templates.

Install

npm install html-factory

How To Use

  1. First, edit the template
  2. Then edit the Excel
  3. Convert object array coming from Excel to last

template edit

I follow the notation of the mustache

sample

View:

{
  "name": {
    "first": "Michael",
    "last": "Jackson"
  },
  "age": "RIP"
}

Template:

* {{name.first}} {{name.last}}
* {{age}}

Output:

* Michael Jackson
* RIP

See below for details

Convert object array

object'template' and object'path' is required.

  • File is saved in dest folder while maintaining the structure of the value of object'path'
  • look for a object'template' value file from a template folder
var Factory = require('html-factory');

new Factory.Model().fetch('./src/spreadsheets/data.xlsx').then(function (array) {

  array.shift();

  var data = array.map(function (e, i) {
    return {
      path:     e[0],
      template: e[1],
      name: {
        first: e[2],
        last:  e[3]
      },
      stooges: e.slice(4, 7).map(function(e, i) {
        return {
          name: e
        }
      }),
      musketeers: e.slice(7)
    }
  });

  Factory.inspect(data);

  data.forEach(function (e, i) {
    new Factory.View().dump(e);
  });

});

test command

$ npm test

start command

$ npm start