Merge multiple files into a single namespace
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 459
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Migrated issue, originally created by Ben Beanfield (@benbeanfield)
It would be great if functions or tags defined in multiple template files could be added to the same namespace. This would allow for the creation of widget libraries without having to put every function or tag into one file in order to access them from the same namespace.
For example:
## /foo.mako
<%namespace name="forms" file="/forms/input.mako" inheritable="True">
<%namespace name="forms" file="/forms/textarea.mako" inheritable="True">
<%namespace name="forms" file="/forms/button.mako" inheritable="True">
## Each of the above template files defines a single def, which would be accessed with:
$(forms.input()}
$(forms.textarea()}
$(forms.button()}
Or alternatively:
## /foo.mako
<%namespace name="forms" files=${['/forms/input.mako', '/forms/textarea.mako', '/forms/button.mako']}>
$(forms.textarea()}
Further, it would be great if a single file could be used to import all of the individual template files into a single namespace, and then this single file could be used by other templates.
For example:
## /forms/index.mako
<%namespace name="forms" file="/forms/input.mako" inheritable="True" import="*">
<%namespace name="forms" file="/forms/textarea.mako" inheritable="True" import="*">
<%namespace name="forms" file="/forms/button.mako" inheritable="True" import="*">
## /foo.mako
<%namespace name="forms" file="/forms/index.mako">
$(forms.input()}
$(forms.textarea()}
$(forms.button()}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the namespace examples in /foo.mako and /forms/index.mako with the individual /forms/input.mako, /forms/textarea.mako, and /forms/button.mako files. The work is done when multiple template files can expose their definitions through one namespace, including the index-file import example, without requiring all definitions in one file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100