JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 572
  • Score
    100M100P100Q88586F
  • License MIT

Create HTML tag strings on the fly.

Package Exports

  • get-tag
  • get-tag/dist/get-tag.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-tag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-tag

Create HTML tag strings on the fly.

Installation

Install the plugin from npm:

npm install get-tag

Usage

const getTag = require("get-tag");

getTag("title", "Some Title");
// <title>Some Title</title>

getTag("a", "Some Link", {href: "foo.com"});
// <a href="foo.com">Some link</a>

getTag("meta", null, {name: "author", content: "foo"});
// <meta name="author" content="foo">

Details

/**
 * @param {string} tag HTML tag name.
 * @param {string} textContent Text content for the element.
 * @param {Attributes} attributes Object representing attribute key/value pairs.
 * @param {boolean} selfClosing Boolean representing a self closing element. Default: false
 * @return {string} A string representing the constructed HTML element.
 */
getTag(tag, textContent, attributes, selfClosing);

License

MIT