getnikola / plugins

Extra plugins for Nikola
https://plugins.getnikola.com/
MIT License
57 stars 93 forks source link

[v8-orgmode] apply_shortcodes() context don't include variable "post" #302

Closed littlemo closed 5 years ago

littlemo commented 5 years ago
PythonAction Error
Traceback (most recent call last):
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/doit/action.py", line 424, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/post.py", line 645, in compile
    lang)
  File "/Users/moore/Develop/moblog/pelican/source/plugins/orgmode/orgmode.py", line 76, in compile
    output, shortcode_deps = self.site.apply_shortcodes(inf.read())
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1628, in apply_shortcodes
    return shortcodes.apply_shortcodes(data, self.shortcode_registry, self, filename, lang=lang, extra_context=extra_context)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/shortcodes.py", line 371, in apply_shortcodes
    res = f(*args, **kw)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1569, in render_shortcode
    output = self.template_system.render_template_to_string(t_data, context)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/template/mako.py", line 123, in render_template_to_string
    return Template(template, lookup=self.lookup).render(**context)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/mako/template.py", line 462, in render
    return runtime._render(self, self.callable_, args, data)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/Users/moore/.virtualenvs/nikola/lib/python3.5/site-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x10dbfaba8", line 31, in render_body
AttributeError: 'Undefined' object has no attribute 'author'

Nikola 8.0.2

I use post.author() in my shortcodes tmpl, but I don't got it. The same shortcodes can use on builtin format, rst and md.

Have any idea? tks~~

littlemo commented 5 years ago

I fixed it on PR #303 ~~