Skip to main content

Mikoblocks is a minimal library to programmatically generate html. It is unopinionated and outputs pure html code and due to a small simple syntax the programming is much easier and clearer to type compared to html. It allows assembling of component "blocks" which can nest further components within, allowing complex reusable pieces to be shared across pages and projects.

const { Block } = import('mikoblocks');

class MikoblocksExamplePage extends Block {

    constructor() {
        super();
        this.raw('<!doctype html>');
        let html = this.tag('html');
        let head = html.tag('head');
        let body = html.tag('body');
        body.tag('div', { id: "content", class: "example-class" }).raw("Hello World!");
    }

}

let page = new MikoblocksExamplePage();
console.log(page.toHtml());

Installation

npm install mikoblocks

Uses

Mikoblocks can be used as a prebuild process to output static html pages and it can also be run on the server dynamically to generate html at runtime.

  • Programmatically generate your entire website from one script. Define components for header, footer, menus, buttons whatever you like and combine them all to output your entire page.
  • Use mikoblocks on the server to dynamically generate pages with common shared elements.

Guide

Mikoblocks elegantly only uses 4 functions.

Block

A block is a beginning structure of a mikoblock, on it's own it has no output but can hold a list of sub-blocks. This is what empowers it over dom programming in that a block be be an element akin to an object or a list of elements akin to a list.

Tag

A tag is any xml tag that has a paired closing tag. You define the tag name and any attributes on the block itself.

Void

A void is any xml block that doesn't have a closing tag. You define the tag name and any attributes on the block itself.

Raw

Raw outputs text, it can hold text representations of further html or be the text between the opening and closing of an html block.

Outputs

Any mikoblock can use the .toHtml() function to output text based html of itself and all nested blocks. That's it, pretty simple huh?

toHtml()

Outputs the block into html text including all nested blocks.

Metadata

Release files for mikoblocks 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mikoblocks 0.1.2
File Size Uploaded
mikoblocks-0.1.2.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mikoblocks 0.1.2
File Interpreter ABI Platform
mikoblocks-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / mikoblocks-0.1.2.tar.gz

Download URL mikoblocks-0.1.2.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b3b16adbd31081c2f31561e69b6478047c95f3ff59189c3da657a9250947657b
BLAKE2b-256 checksum
How to use checksums
63715fb7ed8a08ea1864f1b7db3f099fea6d8fb325c10651aa16cf1c96a3f735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release files / mikoblocks-0.1.2-py3-none-any.whl

Download URL mikoblocks-0.1.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b18c8a0770184a24f8a1322133c58a7977d79dddd518dca3418d1a3ca19c118c
BLAKE2b-256 checksum
How to use checksums
23de479b90558dd649547ef68c2015d407df1da34779a1a3a1ee00b1c5516dea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page