Socket
Book a DemoInstallSign in
Socket

create-html-element

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-html-element

Create a HTML element string

latest
Source
npmnpm
Version
5.0.0
Version published
Weekly downloads
1.3K
-28.08%
Maintainers
1
Weekly downloads
 
Created
Source

create-html-element

Create a HTML element string

Install

npm install create-html-element

Usage

import createHtmlElement from 'create-html-element';

createHtmlElement({
	name: 'h1',
	attributes: {
		class: 'unicorn',
		rainbow: true,
		horse: false,
		number: 1,
		multiple: [
			'a',
			'b'
		]
	},
	html: '🦄'
});
//=> '<h1 class="unicorn" rainbow number="1" multiple="a b">🦄</h1>'

createHtmlElement({text: 'Hello <em>World</em>'});
//=> '<div>Hello &lt;em&gt;World&lt;/em&gt;</div>'

API

createHtmlElement(options)

options

Type: object

name

Type: string
Default: 'div'

HTML tag name.

attributes

Type: object

HTML tag attributes.

html

HTML tag value in unescaped HTML.

This option is mutually exclusive with the text option.

text

HTML tag value in escaped HTML.

This option is mutually exclusive with the html option.

  • stringify-attributes - Turn an object into a string of HTML attributes

Keywords

html

FAQs

Package last updated on 18 Nov 2024

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