@lydio/html
v3.0.2
Published
Direct HTML element classes for Lydio
Downloads
16
Maintainers
Readme
@lydio/html
Canonical URL: https://alexstevovich.com/a/lydio-html-nodejs
Software URL: https://midnightcitylights.com/software/lydio-html-nodejs
Direct HTML element classes for Lydio.
@lydio/html provides a direct, class-based interface for working with standard HTML tags in Lydio.
It includes pre-defined node types for common elements — from <html> and <body> to <a>, <img>, <meta>, and more — allowing clean, programmatic HTML generation.
Installation
npm install @lydio/htmlExample
import { Dom, Html, A, Img, Ul } from '@lydio/html';
const dom = new Dom();
const html = dom.html;
html.head.addLeaf('meta').withAttribute('charset', 'utf-8');
const list = new Ul();
list.addItem().withText('First');
list.addItem().withText('Second');
html.body
.addNode(new A().withHref('https://example.com').withText('Visit Site'))
.addNode(new Img().withSrc('logo.png').withAlt('Logo'))
.addNode(list);
console.log(dom.toHtml());
/*
<!DOCTYPE html><html lang="en-US"><head><meta charset="utf-8"></head><body><a href="https://example.com">Visit Site</a><img src="logo.png" alt="Logo"><ul><li>First</li><li>Second</li></ul></body></html>
*/Available Classes
- Html — Root
<html>element withlangsupport. - Dom — Includes
<!DOCTYPE html>and a prebuiltHtmlinstance. - Link — Creates a
<link>tag for stylesheets or canonical references. - Script — Adds a
<script>element with helpers forsrc,type, andloading. - Meta — Base
<meta>tag. - MetaName —
<meta name="..." content="...">convenience class. - MetaProperty —
<meta property="..." content="...">convenience class. - A — Anchor element with helpers for
href,aria-label, and external links. - Img — Image element with
srcandaltattributes. - Ul / Ol — List elements with an
.addItem()method for adding<li>entries.
License
Licensed under the Apache License 2.0.
Trademark
“Lydio” and related marks are trademarks of Alex Stevovich.
See TRADEMARK.md for details.
