1.2.0 • Published 3 years ago

hachescript v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

hachescript

npm.io npm.io npm.io npm.io

Create HTML strings using JavaScript, anywhere. Like Hyperscript but faster, and without the overhead of creating actual HTML elements.

Installation

Using npm, npm i hachescript.

Using yarn, yarn add hachescript.

Usage

Using import

import { h } from 'hachescript';

const str = h(
  'div#myId.myClass', // the selector. supports ID and multiple classes
  'hello world', // The content. Can be a simple string, another HTML tag created by hachescript, or an array of them
  {
    dataIndex: 'hello',
    class: ['text-muted', 'text-primary'],
  } // Additional attributes. camelCase will be converted to kebab-case
);

// str is '<div id="myId" class="myClass text-muted text-primary" data-index="hello">hello world</div>'

In a CommonJS environment

const { h } = require('hachescript');

const str = h(
  'img', // self closing tags will be detected
  '', // Always provide a content nevertheless
  {
    src: 'dog.png',
    class: 'rounded',
  }
);

// str is '<img class="rounded" src="dog.png"/>'

Documentation

See DOCS

1.2.0

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago