-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Description
What problem does this feature solve?
The Vue docs give the following example of a case where a render function might be convenient:
<script type="text/x-template" id="anchored-heading-template">
<h1 v-if="level === 1">
<slot/>
</h1>
<h2 v-else-if="level === 2">
<slot/>
</h2>
<h3 v-else-if="level === 3">
<slot/>
</h3>
<h4 v-else-if="level === 4">
<slot/>
</h4>
<h5 v-else-if="level === 5">
<slot/>
</h5>
<h6 v-else-if="level === 6">
<slot/>
</h6>
</script>
However, it seems to me that with the addition of only a single syntax keyword --perhaps "tag"-- templates could provide the same functionality as the render() function does through its first tag string return value.
What does the proposed API look like?
With tagName
being a JavaScript variable (e.g., tagName = 'h1'
):
<tag="tagName">foo</tag>
Or maybe something like:
<{ tagName }>foo</>
Or maybe:
<template tag="tagName">foo</template>
I wouldn't be surprised if this idea was already considered and discarded for good reasons, but I figured I'd throw this feature request out here anyway for discussion and future reference.
wenfangdu and grdscrcwilokecom
Metadata
Metadata
Assignees
Labels
No labels