Skip to content

Commit 7098fb2

Browse files
committed
Add html option
1 parent a7357c4 commit 7098fb2

File tree

1 file changed

+3
-1
lines changed
  • packages/babel-plugin-transform-jsx-to-tagged-templates/src

1 file changed

+3
-1
lines changed

packages/babel-plugin-transform-jsx-to-tagged-templates/src/index.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ function escapeValue(value) {
1111
* @param {Babel} babel
1212
* @param {object} [options]
1313
* @param {string} [options.tag='html'] The tagged template "tag" function name to produce.
14+
* @param {string} [options.html=false] If `true`, output HTML-like instead of XML-like (no self-closing tags, etc).
1415
*/
1516
export default function jsxToTaggedTemplatesBabelPlugin({ types: t }, options = {}) {
1617
const tag = dottedIdentifier(options.tag || 'html');
18+
const htmlOutput = !!options.html;
1719

1820
function dottedIdentifier(keypath) {
1921
const path = keypath.split('.');
@@ -82,7 +84,7 @@ export default function jsxToTaggedTemplatesBabelPlugin({ types: t }, options =
8284
}
8385
}
8486

85-
if (node.children && node.children.length !== 0) {
87+
if (htmlOutput || node.children && node.children.length !== 0) {
8688
raw('>');
8789
for (let i = 0; i < node.children.length; i++) {
8890
let child = node.children[i];

0 commit comments

Comments
 (0)