Socket
Book a DemoInstallSign in
Socket

argon-html

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argon-html

HTML template tag to convert template string to DOM nodes

0.0.15
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

CodeQL

Argon HTML

HTML template tag to convert template string to DOM nodes

Install

npm i argon-html

Usage

Covert template string to compatible HTML string

Simple example:

import { htmlString } from "argon-html";

const text = "Hello World!";

const htmlStr = htmlString`
  <div class="container">
    <div class="text">${text}</div>
  </div>
`;

console.log(htmlStr);

/**
 * Output:
 *
 * <div class="container">
 *  <div class="text">Hello World</div>
 * </div>
 */

Complex example:

import { htmlString } from "argon-html";

const text = [
  '<div class="text">Hello</div>',
  '<div class="text">World</div>',
  { key: "value" },
];

const htmlStr = htmlString`
  <div class="container">
    ${text}
  </div>
`;

console.log(htmlStr);

/**
 * Output:
 *
 * <div class="container">
 *  <div class="text">Hello</div>
 *  <div class="text">World</div>
 *  {"key": "value"}
 * </div>
 */

Convert template string to DocumentFragment

import { html } from "argon-html";

const text = [
  '<div class="text">Hello</div>',
  '<div class="text">World</div>',
  { key: "value" },
];

const fragment = html`
  <div class="container">
    ${text}
  </div>
`;

console.log(fragment);

document.body.appendChild(fragment);

/**
 * Output:
 *
 * <DocumentFragment>
 *  <div class="container">
 *    <div class="text">Hello</div>
 *    <div class="text">World</div>
 *    {"key": "value"}
 *  </div>
 * </DocumentFragment>
 */

Keywords

template

FAQs

Package last updated on 19 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.