Skip to content

Support dynamic values for webc:import component imports #148

Description

@ashur

Summary

WebC's webc:import attribute currently supports static strings, like:

<any-tag-name webc:import="./components/my-component.webc"></any-tag-name>

It would be extremely helpful if it also supported dynamic values — ex., paths constructed using values in the data cascade.

Example

Building on WebC's existing :-prefixed syntax for dynamic attributes, a dynamic import might use :webc:import:

---
component: my-component
---
<any-tag-name :webc:import="'./components/' + component + '.webc'"></any-tag-name>

Usage

We make heavy use of Nunjucks's support for dynamically include-ing templates and import-ing macros when building pages from user-defined data in a CMS.

Activity

  1. changed the title [-]Consider supporting dynamic values for component imports[/-] [+]Support dynamic values for `webc:import` component imports[/+] on Mar 31, 2023
  2. ashur commented on Jul 2, 2023

    @ashur
    Author

    The more I play with with WebC in Eleventy, the more I think #143 would better fit the bill for approximating dynamic includes in Nunjucks 👍

    (I’ll leave this open in case there’s a scenario where a dynamic webc:import is more appropriate)

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