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

'NoneType' has no attribute start when calling {% url %} on #[a(href)]-style tags #51

Open
ewen-lbh opened this issue May 10, 2019 · 1 comment

Comments

@ewen-lbh
Copy link

  • pypugjs version:5.8.1
  • Django version:2.2.1
  • Python version:3.6.8
  • Operating System:Linux Pop!_OS 18.10

Description

I was trying to incorporate a url block in a embedded anchor tag's href:

p Test and #[a.thing(href="{% url 'stuff' %}") lorem ipsum]

What I Did

Traceback:

Internal Server Error: /news/subscribe
Traceback (most recent call last):
  File "/home/ewen/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ewen/Coding/projects/mx3creations/newsletter/views.py", line 27, in subscribe
    return render(request, 'subscribe.pug', locals())
  File "/home/ewen/.local/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/engine.py", line 143, in get_template
    template, origin = self.find_template(template_name)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/engine.py", line 125, in find_template
    template = loader.get_template(name, skip=skip)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/ext/django/loader.py", line 43, in get_template
    return super(cached.Loader, self).get_template(template_name, **kwargs)
  File "/home/ewen/.local/lib/python3.6/site-packages/django/template/loaders/base.py", line 24, in get_template
    contents = self.get_contents(origin)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/ext/django/loader.py", line 33, in get_contents
    contents, filename=origin.template_name, compiler=Compiler
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/utils.py", line 232, in process
    block = _parser.parse()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 52, in parse
    block.append(self.parseExpr())
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 91, in parseExpr
    return self.parseExpr()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 95, in parseExpr
    return getattr(self, funcName)()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 363, in parseTag
    block = self.block()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 273, in block
    block.append(self.parseExpr())
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 95, in parseExpr
    return getattr(self, funcName)()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 188, in parseConditional
    node.block = self.block()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 273, in block
    block.append(self.parseExpr())
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 95, in parseExpr
    return getattr(self, funcName)()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 363, in parseTag
    block = self.block()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 273, in block
    block.append(self.parseExpr())
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 95, in parseExpr
    return getattr(self, funcName)()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 354, in parseTag
    while 'newline' == self.peek().type:
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 35, in peek
    p = self.lookahead(1)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/parser.py", line 42, in lookahead
    return self.lexer.lookahead(n)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 139, in lookahead
    self.stash.append(self.next())
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 715, in next
    or self.string()
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 367, in string
    return self.scanInlineProcess(self.RE_STRING, 'string')
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 357, in scanInlineProcess
    toks = self.scanInline(regexp, type_)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 348, in scanInline
    ret = self.processInline(ret.val)
  File "/home/ewen/.local/lib/python3.6/site-packages/pypugjs/lexer.py", line 308, in processInline
    start_inline = self.RE_INLINE.search(sval_replaced).start()
AttributeError: 'NoneType' object has no attribute 'start'
@kakulukia
Copy link
Owner

Maybe thats not even supported by the current lexer .. tho totally valid i bet its not expecting that :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants