Closed tmzhuang closed 4 years ago
ouch .. im kindy buisy right now and cant solve this in the near future, tho :/
No problem, thanks for forking this project at all. I can't stand vanilla HTML.
I believe it's in ext/django/loader.py:
def include_pug_sources(self, contents):
"""Lets fetch top level pug includes to enable mixins"""
match = re.search(r'^include (.*)$', contents, re.MULTILINE)
if match:
mixin_name = match.groups()[0]
origin = [o for o in self.get_template_sources(mixin_name)][0]
template = origin.loader.get_contents(origin)
template = self.include_pug_sources(template)
contents = re.sub(r'^include (.*)$', template, contents, flags=re.MULTILINE)
return contents
def get_contents(self, origin):
if os.path.splitext(origin.template_name)[1] in ('.pug', '.jade'):
contents = origin.loader.get_contents(origin)
contents = self.include_pug_sources(contents)
contents = process(
contents, filename=origin.template_name, compiler=Compiler
)
else:
contents = origin.loader.get_contents(origin)
return contents
I'll take a look if I have time, but I don't have a lot of experience.
Hmmm, I'm having issues running the test suite:
After "make init" and "make test":
...............................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 271 tests in 1.115s
OK
make[1]: Entering directory '/home/tianming/proj/pypugjs'
pypugjs/testsuite/test_inline_lexer.py:5:16: W605 invalid escape sequence '\#'
make[1]: *** [Makefile:32: lint] Error 1
make[1]: Leaving directory '/home/tianming/proj/pypugjs'
make: *** [Makefile:36: test] Error 2
Any pointers?
Thats kinda weird since the file was not touched lately and im not getting that error. And there is just a single # in line 178
Try removing that backslash and if that helps keep it that way since it looks off place anyway.
Oh nooo .. forget what i just said .. the test ist testing that you can actually have a string "#[anything]" in your code .. that should stay as is.
Whats your version of flake8 --version /Users/andy/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1 EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]') 3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.7.0 on Darwin
Okay, found the real error. flake8 is installed without version constraint and got updated to version 3.6 21 days ago.
Please make another exception to the default flake8 rules in setup.cfg line 12. Add W605 and the tests will be fine again.
pypugjs version: Django version: Python version: Operating System:
Description
Nested includes raises django.template.exceptions.TemplateDoesNotExist even though the specified template is in the app_directories the loader tries.
What I Did
namespace/x/a.pug:
namespace/y/a.pug:
This works as intented if namespace/y/a.pug does not have includes.