/polenta

:corn: Create html with JS. As simple as that.

Primary LanguageJavaScriptMIT LicenseMIT

Polenta

Build status JavaScript Style Guide npm bundle size GitHub GitHub stars

A tool with modern JS in mind

Polenta?

Polenta (/pəˈlɛntə, poʊˈ-/, Italian: [poˈlɛnta]) is a dish of boiled cornmeal that was historically made from other grains. It may be served as a hot porridge, or it may be allowed to cool and solidify into a loaf that can be baked, fried, or grilled.

Polenta is a simple dish, that may have a simple flavor, but when combined with the right stuff, becomes incredible.

This package exposes functions for each html tag and a render function to generate elements using either Shadow DOM or regular DOM. Nothing else.

Installation

Just run yarn add polenta or npm install polenta if you have a module bundler set up

Usage

A simple use case would be:

In your index.html file:

...
<div id="root"></div>
<script type="module" src="./path/to/yourFile.js">

And on yourFile.js:

import * as polenta from 'https://www.unpkg.com/polenta@1.0.4/index.js' //
assuming no webpack is to be found

const content = polenta.div('id="my-div" class="blue big"',
  polenta.p('class="my-text"', "Hello World"))

polenta.render(content, 'root')

Just functions, no boilerplate, no dependencies, 1.56KB.