Skip to content

Commit 8e241c6

Browse files
committed
Add support for compiling <template>s content
1 parent ba266eb commit 8e241c6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var SO = '/';
2727
/* Stringify an element `node`. */
2828
function element(ctx, node, index, parent) {
2929
var name = node.tagName;
30-
var content = all(ctx, node);
30+
var content = all(ctx, name === 'template' ? node.content : node);
3131
var selfClosing = ctx.voids.indexOf(name.toLowerCase()) !== -1;
3232
var attrs = attributes(ctx, node.properties);
3333
var omit = ctx.omit;

test/element.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,27 @@ test('`element`', function (t) {
5353
'attribute ends with `/`'
5454
);
5555

56+
t.deepEqual(
57+
to({
58+
type: 'element',
59+
tagName: 'template',
60+
properties: {},
61+
children: [],
62+
content: {
63+
type: 'root',
64+
children: [
65+
h('p', [
66+
h('b', 'Bold'),
67+
' and ',
68+
h('i', 'italic'),
69+
'.'
70+
])
71+
]
72+
}
73+
}),
74+
'<template><p><b>Bold</b> and <i>italic</i>.</p></template>',
75+
'should support `<template>`s content'
76+
);
77+
5678
t.end();
5779
});

0 commit comments

Comments
 (0)