Skip to content

Commit

Permalink
Merge pull request developit#179 from developit/terse-option
Browse files Browse the repository at this point in the history
Add `terse` option
  • Loading branch information
jviide committed Sep 23, 2020
2 parents e241d3a + 877867e commit ed1c620
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/babel-plugin-transform-jsx-to-htm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import jsx from '@babel/plugin-syntax-jsx';
* @param {Babel} babel
* @param {object} [options]
* @param {string} [options.tag='html'] The tagged template "tag" function name to produce.
* @param {boolean} [options.terse=false] Output `<//>` for closing component tags
* @param {string | boolean | object} [options.import=false] Import the tag automatically
*/
export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
Expand Down Expand Up @@ -130,9 +131,14 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {

if (!isFragment) {
if (isComponentName(name)) {
raw('</');
expr(name);
raw('>');
if (options.terse) {
raw('<//>');
}
else {
raw('</');
expr(name);
raw('>');
}
}
else {
raw('</');
Expand Down

0 comments on commit ed1c620

Please sign in to comment.