object-to-dom
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Object to DOM

Generate dom element from object.

This package is only for client side rendering based apps as React.js or Vue.js apps

Example

export const example = el<"div">({
  tag: "div",
  className: "flex flex-col gap-3",
  children: [
    el<"span">({
      tag: "span",
      className: "text-xl font-bold",
      children: "Card from object",
      beforeChildrenRendering: (instance) => {
        // component rendered
      },
    }),
    el<"p">({
      tag: "p",
      className: "text-base font-thin",
      children:
        "lorem ipsum dolor si amet, patati patata lorem dollor sit amet, fuck religion so on and so fort.",
    }),
  ],
});

Rendering

import { example, renderNode } from "object-to-dom";

// render the example to an html element
const htmlElement = renderNode(example);

// You can now include the generated element in the dom
// document.getElementById("#root")?.append(htmlElement);

Install

npm i object-to-dom

DownloadsWeekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

15.5 kB

Total Files

9

Last publish

Collaborators

  • lambou