11ty / 11ty/webc

Support dynamic values for `webc:import` component imports

Open
#148 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
1.4k
Forks
46
Avg merge
10m
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of WebC's webc:import attribute and the existing :-prefixed dynamic-attribute handling. Check how data-cascade expressions are evaluated and determine the expected behavior for a computed component path; done should include dynamic imports using the documented example and coverage for the resulting component selection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.