1.0.2 • Published 1 year ago
obj-ui v1.0.2
obj-ui
obj-ui
is an npm package for creating static HTML webpages with object-oriented JavaScript
Overview
obj-ui
exports three main classes and two extends
classes.
Main classes
- The App class represents directory of HTML pages, equivalent to a simple static website.
- The Page class represents a HTML page.
- The Component class represents a HTML element.
Sub-classes
The Head and Body, classes, which represent head
and body
html elements respectively, both extend the Component class.
Quickstart
- Make a new, empty directory and use npm or yarn to install
obj-ui
- Create an
index.js
file and add the following code:
const { App } = require('obj-ui')
const app = new App({ outDir: 'build', lang: 'en' })
app.page('index', indexPage => {
indexPage.head(headComponent => {
headComponent.child('title', titleComponent => {
titleComponent.text('Hello, world!')
})
})
indexPage.body(bodyComponent => {
bodyComponent.child('h1', heading => {
heading.text('Hello, world!')
})
})
})
app.build()
- Run
node index.js
from the working directory. A/build
folder should be generated automatically in the root directory. - Open
/build/index.html
. - Browse the API Docs