🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

html-tag-helpers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-tag-helpers

Easily generate helpers for creating HTML tags. Works great as handlebars helpers or vanilla javascript utils.

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

html-tag-helpers NPM version

Easily generate helpers for creating HTML tags. Works great as handlebars helpers or vanilla javascript utils.

Install

Install with npm:

npm i html-tag-helpers --save-dev

Usage

Create a new instance of Tags:

var Tags = require('html-tag-helpers');
var html = new Tags();

Tags

Generate a function to create any HTML tag:

var apple = html.addTag('apple');

// pass text as the first parameter, and an object of
// attributes as the second param.
console.log(apple('a', {href: 'b'})
//=> '<apple href="b">a</apple>'

// or pass text as a property
console.log(apple({href: 'b', text: 'a'})
//=> '<apple href="b">a</apple>'

Default attributes

Pass default attributes as a second paramter:

var css = html.addTag('link', {rel: 'stylesheet'});
console.log(css({href: 'styles.css'}));
//=> <link href="styles.css" rel="stylesheet">

As Handlebars helpers

To create a handlebars helper:

Handlebars.registerHelper('orange', tag.addTag('orange'));

var tmpl = Handlebars.compile('{{{orange "This is text" href=link}}}');
console.log(tmpl({link: 'about/us.html'}));
//=> '<orange href="about/us.html">This is text</orange>'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license

This file was generated by verb-cli on August 21, 2014.

Keywords

attr

FAQs

Package last updated on 21 Aug 2014

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