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

static_comments: compare to None not none in templates #273

Merged
merged 1 commit into from May 9, 2018
Merged

static_comments: compare to None not none in templates #273

merged 1 commit into from May 9, 2018

Conversation

evgeni
Copy link
Contributor

@evgeni evgeni commented May 9, 2018

No description provided.

@felixfontein
Copy link
Contributor

For jinja2, it must be none and not None. No idea about Mako, though :)

@evgeni
Copy link
Contributor Author

evgeni commented May 9, 2018

@felixfontein mako wants None, I did not test jinja, so amended the commit to only touch mako templates

@felixfontein
Copy link
Contributor

Sounds good! I must admit that I haven't tested the Mako versions...

@evgeni
Copy link
Contributor Author

evgeni commented May 9, 2018

I noticed ;)

@felixfontein felixfontein merged commit a857387 into getnikola:master May 9, 2018
@felixfontein
Copy link
Contributor

Thanks for fixing this!

@Kwpolska
Copy link
Member

Kwpolska commented May 9, 2018

I think None works in Jinja2 as well.

@felixfontein
Copy link
Contributor

None works, but is None does not. At least, it used to not work...

@felixfontein
Copy link
Contributor

import jinja2
print(jinja2.Environment().from_string('{% if None is none %}A{% else %}B{% endif %}').render())
print(jinja2.Environment().from_string('{% if None is None %}A{% else %}B{% endif %}').render())

This prints A and then dies with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 880, in from_string
    return cls.from_code(self, self.compile(source), globals, None)
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 591, in compile
    self.handle_exception(exc_info, source_hint=source_hint)
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<unknown>", line 1, in template
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 543, in _generate
    optimized=self.optimized)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 82, in generate
    generator.visit(node)
  File "/usr/lib/python3.6/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 754, in visit_Template
    self.blockvisit(node.body, frame)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 378, in blockvisit
    self.visit(node, frame)
  File "/usr/lib/python3.6/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 1157, in visit_If
    self.visit(node.test, if_frame)
  File "/usr/lib/python3.6/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 70, in new_func
    return f(self, node, frame, **kwargs)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 1607, in visit_Test
    self.fail('no test named %r' % node.name, node.lineno)
  File "/usr/lib/python3.6/site-packages/jinja2/compiler.py", line 315, in fail
    raise TemplateAssertionError(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateAssertionError: no test named 'None'

Kwpolska added a commit to getnikola/nikola that referenced this pull request May 9, 2018
h/t @felixfontein — via getnikola/plugins#273

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
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

Successfully merging this pull request may close these issues.

None yet

3 participants