lego icon indicating copy to clipboard operation
lego copied to clipboard

Allow to encapsulate multiple tags having the same directive within a <template> tag

Open mlbiche opened this issue 7 months ago • 0 comments

In order to lighten the following code:

<p :if="state.counter < 5">1</p>
<p :if="state.counter < 5">2</p>
<p :if="state.counter < 5">3</p>
<p :if="state.counter < 5">4</p>
<p :if="state.counter < 5">5</p>

we would prefer having the following syntax:

<template :if="state.counter < 5">
  <p>1</p>
  <p>2</p>
  <p>3</p>
  <p>4</p>
  <p>5</p>
</template>

Currently, the <template> tag is inserted in the DOM, resulting in the <p> tags not being displayed. It would be nice if LEGO would directly insert in the DOM the <p> tags.

Sure, we still can do:

<div :if="state.counter < 5">
  <p>1</p>
  <p>2</p>
  <p>3</p>
  <p>4</p>
  <p>5</p>
</div>

But for the few nerds in this world that (as I do) still attach importance to lightening the DOM and dissociating the logic from the template structure and that have allergic reactions to <div> Christmas trees, it would be nice to be able to use the <template> tag as previously mentioned.

Let's see in the future if this feature is worth investing time and complexity in it. For now, I can live with it! 🤙

mlbiche avatar Jun 11 '25 09:06 mlbiche