1. create-html-element
Create a HTML element string
create-html-element
Package: create-html-element
Created by: sindresorhus
Last modified: Sat, 17 Jun 2023 00:14:10 GMT
Version: 4.0.1
License: MIT
Downloads: 3,868
Repository: https://github.com/sindresorhus/create-html-element

Install

npm install create-html-element
yarn add create-html-element

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin