Skip to content

Support dynamic :webc:is value #143

Description

@m4rrc0

Hey! Doesn't seem like an urgent fix but...
This does not work properly (or at least not as I expected):

<div :webc:is="'my-component'" @test="Dynamic comp name does not pass props"></div>

The component renders but the test prop is not passed.

The workaround is probably to use a script.

<script webc:type="js">
  `<${"my-component"} @test="Template string comp name works"></${"my-component"}>`
  + // OR
  `<div webc:is="${"my-component"}" @test="Template string comp name works"></div>`;
</script>

Both work as expected.

My use case was the following:
I wanted to loop over an array of data with each entry containing the name of the component to be used and the props to be passed to said component.
I was trying something like this:

<div
  webc:for="block of blocks"
  :webc:is="block.tag"
  @attributes="block"
></div>

It looks super neat and compact! (but it does not work 😭😄)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions