Skip to content

Commit ed1c620

Browse files
authored
Merge pull request #179 from developit/terse-option
Add `terse` option
2 parents e241d3a + 877867e commit ed1c620

File tree

1 file changed

+9
-3
lines changed
  • packages/babel-plugin-transform-jsx-to-htm

1 file changed

+9
-3
lines changed

packages/babel-plugin-transform-jsx-to-htm/index.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import jsx from '@babel/plugin-syntax-jsx';
44
* @param {Babel} babel
55
* @param {object} [options]
66
* @param {string} [options.tag='html'] The tagged template "tag" function name to produce.
7+
* @param {boolean} [options.terse=false] Output `<//>` for closing component tags
78
* @param {string | boolean | object} [options.import=false] Import the tag automatically
89
*/
910
export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
@@ -130,9 +131,14 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
130131

131132
if (!isFragment) {
132133
if (isComponentName(name)) {
133-
raw('</');
134-
expr(name);
135-
raw('>');
134+
if (options.terse) {
135+
raw('<//>');
136+
}
137+
else {
138+
raw('</');
139+
expr(name);
140+
raw('>');
141+
}
136142
}
137143
else {
138144
raw('</');

0 commit comments

Comments
 (0)