Subscribe on changes!

[FR] Optional root `<template>` when the templating language is html

avatar
Jun 21st 2023

What problem does this feature solve?

Currently, when authoring components in SFC, we have to add a root <template> tag:

<script lang="ts" setup>
  // ...
</script>

<template>
  <div>Content</div>
</template>

Would be nice to be able to omit the root <template> tag when the templating language is html:

<script lang="ts" setup>
  // ...
</script>

<div>Content</div>

The above syntax is closer to writing html files, therefore more natural and intuitive, Svelte does this by default, would be great if Vue supports it too.

What does the proposed API look like?

<script lang="ts" setup>
  // ...
</script>

<div>Content</div>
avatar
Jun 21st 2023

this is planned in Vapor mode

avatar
Jun 21st 2023

@edison1105 Where is it documented and how can I try it?

avatar
Jun 22nd 2023

Not available for now. It's just a thought.

avatar
Jun 28th 2023

@Shyam-Chen This issue has nothing to do with pug, and the optional root <template> should be enabled only when the templating language is html.