Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamic values for webc:import component imports #148

Open
ashur opened this issue Mar 27, 2023 · 1 comment
Open

Support dynamic values for webc:import component imports #148

ashur opened this issue Mar 27, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ashur
Copy link

ashur commented Mar 27, 2023

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.

@zachleat zachleat added the enhancement New feature or request label Mar 28, 2023
@zachleat zachleat changed the title Consider supporting dynamic values for component imports Support dynamic values for webc:import component imports Mar 31, 2023
@ashur
Copy link
Author

ashur commented Jul 2, 2023

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
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants