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: call mako filters inside a function #275

Merged
merged 1 commit into from May 10, 2018
Merged

static_comments: call mako filters inside a function #275

merged 1 commit into from May 10, 2018

Conversation

@evgeni
Copy link
Contributor

@evgeni evgeni commented May 10, 2018

you can't call mako filters inside python code, you'll get an error like
this instead:

    '<span class="author">' + ('<a href="{0}">{1}</a>'.format(comment.author_url|h, comment.author|h) if comment.author_url is not None else (comment.author|h)) + '</span>',
TypeError: unsupported operand type(s) for |: 'str' and 'Undefined'

move the author line generation into an mako function, which again can
use mako filters

you can't call mako filters inside python code, you'll get an error like
this instead:

        '<span class="author">' + ('<a href="{0}">{1}</a>'.format(comment.author_url|h, comment.author|h) if comment.author_url is not None else (comment.author|h)) + '</span>',
    TypeError: unsupported operand type(s) for |: 'str' and 'Undefined'

move the author line generation into an mako function, which again can
use mako filters
@evgeni
Copy link
Contributor Author

@evgeni evgeni commented May 10, 2018

@felixfontein now the comments render with mako too ;)

@felixfontein
Copy link
Contributor

@felixfontein felixfontein commented May 10, 2018

Meh, I really prefer jinja2 :D

@felixfontein felixfontein merged commit 265b84f into getnikola:master May 10, 2018
1 check passed
@felixfontein
Copy link
Contributor

@felixfontein felixfontein commented May 10, 2018

Again, thanks for fixing this! :)

@evgeni
Copy link
Contributor Author

@evgeni evgeni commented May 10, 2018

@felixfontein heh, yeah. Today I'd use j2 too. But my blog is still using mako and I did not find the time to migrate the custom templates.

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

Successfully merging this pull request may close these issues.

None yet

2 participants