proposal - standardizing directories and template paths
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 jvanasco (@jvanasco)
I've been working on some tools to precompile templates before a webserver forks, and have run into a few issues when trying to build this out more reliably.
-
'directories' can be duplicates. I'm not sure this will affect anything down the line, but it might make sense. this is relatively simple to fix.
lookup = TemplateLookup(directories=['templates', 'templates/', 'templates'])
print lookup.directories
['templates', 'templates', 'templates'] -
filenames aren't standardized, so the same template can become 2 objects/compiled 2 ways (relative vs absolute). this will require more thought.
lookup = TemplateLookup(directories=['templates'])
t1 = lookup.get_template('goodnight_moon.mako')
t2 = lookup.get_template('/goodnight_moon.mako')
print lookup._collection
{'goodnight_moon.mako': <mako.template.Template object at 0x1015df510>, '/goodnight_moon.mako': <mako.template.Template object at 0x1015df850>}
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 with the TemplateLookup directory handling and the get_template path lookup described in the examples, then inspect how lookup.directories and _collection are populated. Define the expected canonical form for duplicate directories and relative versus absolute template names; done means equivalent inputs no longer create duplicate compiled template objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100