1.0.0 • Published 1 year ago

@lucasperovani/html-elements v1.0.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
-
Last release
1 year ago

HTML Elements

A lightweight typescript/javascript library to improve read and write of code generated HTML strings. Each HTML element is a Element class that can be changed after creation and have the HTML re-generated again by calling toHTML function. Another option is provided to use only functions instead of classes. It is a better option to build faster HTML code without calling the toHTML function if dynamic code is not needed.


Examples

  • Use it as classes

import classes from 'html_elements';
const { div, h5, hr } = classes;

const html = div(
    // ID
    'my-element-id',
    // Classes,
    ['py-3', 'mt-0', 'd-flex'],
    // Content
    [hr(), 'Testing content...'],
    // Attributes
    {'data-test': 'success'},
).toHTML();
  • Use it as functions

import functions from 'html_elements';
const { div, h5, hr } = functions;

const html = div(
    // ID
    'my-element-id',
    // Classes,
    ['py-3', 'mt-0', 'd-flex'],
    // Content
    hr() + 'Testing content...',
    // Attributes
    {'data-test': 'success'},
);
1.0.0

1 year ago