Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@phtml/self-closing

phtmlorg18CC0-1.04.2.0

Use self-closing tags in HTML

phtml, html, phtml-plugin, self, closing, tag, short, hand, compress, sugar

readme

pHTML Self Closing pHTML

NPM Version Build Status Support Chat

pHTML Self Closing lets you use self-closing tags in HTML.

<div><div class="main"/></div>
<template><slot name="title"/></template>
<custom-element/>

<!-- becomes -->

<div><div class="main"></div></div>
<template><slot name="title"></slot></template>
<custom-element></custom-element>

Note: The <script> and <style> tags are ignored.

Usage

Transform HTML files directly from the command line:

npx phtml source.html output.html -p @phtml/self-closing

Node

Add pHTML Self Closing to your project:

npm install @phtml/self-closing --save-dev

Use pHTML Self Closing to process your HTML:

const phtmlSelfClosing = require('@phtml/self-closing');

phtmlSelfClosing.process(YOUR_HTML /*, processOptions, pluginOptions */);

Or use it as a pHTML plugin:

const phtml = require('phtml');
const phtmlSelfClosing = require('@phtml/self-closing');

phtml([
  phtmlSelfClosing(/* pluginOptions */)
]).process(YOUR_HTML /*, processOptions */);

pHTML Self Closing runs in all Node environments, with special instructions for:

Node CLI Eleventy Gulp Grunt

Options

ignore

The ignore option defines self-closing elements that will not be expanded.

phtmlSelfClosing({ ignore: 'a' });
<a/>
<custom-element/>
<div/>

<!-- becomes -->

<a/>
<custom-element></custom-element>
<div></div>

The ignore option accepts a string or an array of strings.

phtmlSelfClosing({ ignore: ['a', 'custom-element'] });
<a/>
<custom-element/>
<div/>

<!-- becomes -->

<a/>
<custom-element/>
<div></div>

changelog

Changes to pHTML Self Closing

4.1.0 (May 16, 2019)

  • Updated: phtml to 4.1.0 (minor)

4.0.0 (May 6, 2019)

  • Updated: phtml to 4.0.0 (major)
  • Updated: Node 8+ compatibility (major)

3.0.0 (March 16, 2019)

  • Updated: phtml to 3.0.0 (major)

2.0.0 (February 18, 2019)

  • Updated: phtml to 2.0.1 (major)

1.0.0 (February 13, 2019)

  • Initial version