Static generator for Page framework.
Last updated a year ago by guseyn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @page-libs/static-generator 
SYNC missed versions from official npm registry.


NPM Version Build Status codecov

Static generator for Page framework (based on 'cuties' libs and Async Tree Pattern).


npm install @page-libs/static-generator

Run test

npm test

Run build

npm run build


const {
  // Needed async objects here from the table below  
} = require('@page-libs/static-generator');

Async Object Description Parameters(default value/description) Representation result
Base Creates base tag href, attrs(string like 'attr="value"') <base href=${href} ${attrs}>
Body Creates body tag attrs(string like 'attr="value"'), ...elms(elements inside of body tag) <body ${attrs}>${elms.join('')}</body>
Head Creates head tag ...elms(elements inside of head tag) <head>${elms.join('')}</head>
Link Creates link tag attrs(string like 'attr="value"') <link ${attrs}>
Meta Creates meta tag attrs(string like 'attr="value"') <meta ${attrs}>
NoScript Creates noscript tag text <noscript>${text}</noscript>
Page Creates html tag attrs(string like 'attr="value"'), head, body <!DOCTYPE html>\n<html ${attrs}>${head}${body}</html>\n
PrettyPage Makes page pretty page Pretty html document(page)
SavedPage Saves page to the specified file(as path) path, page file(as path)
Script Creates script tag(for head tag) src, attrs(string like 'attr="value"') <script src="${src}" ${attrs}></script>
Style Creates link tag with rel="stylesheet href, attrs(string like 'attr="value"') <link rel="stylesheet" href="${href}" ${attrs}>
Template Read html as string from the specified file(as path) path html string
TemplateWithParams Replace all placeholders in a template with the specified ...params template, ...params html string
Title Creates title tag text <title>${text}</title>


Let's say we have templates: outer.html, inner.html:

<!-- outer.html -->
<div class="outer">
   {{ text }}
  <div class="place-for-inner-template">
    {{ innerTemplate }}

<!-- inner.html -->
<div class="inner">
   {{ text }}

Then we can create a page that contains these templates:

'use strict'

const {
} = require('@page-libs/static-generator');

new SavedPage(
  new PrettyPage(
    new Page(
      'xmlns="http://www.w3.org/1999/xhtml" lang="en"',
      new Head(
        new Script('script1.js', 'type="text/javascript"'),
        new Script('script2.js', 'type="text/javascript"'),
        new Style('main.css', 'type="text/css"'),
        new Style('mobile.css', 'type="text/css"')
      new Body(
        new TemplateWithParams(
          new Template('outer.html'),
          'text in outer template',
          new TemplateWithParams(
            new Template('inner.html'),
            'text in inner template'

The result is

<!-- page.html -->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

    <script src="script1.js" type="text/javascript"></script>
    <script src="script2.js" type="text/javascript"></script>
    <link rel="stylesheet" href="main.css" type="text/css">
    <link rel="stylesheet" href="mobile.css" type="text/css">

  <body class="main">
    <div class="outer">
      text in outer template
      <div class="place-for-inner-template">
        <div class="inner">
          text in inner template



Full example is here.

Current Tags

  • 1.1.3                                ...           latest (a year ago)

7 Versions

  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |