eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

blog plugin cannot expand template tags #212

Closed kartoch closed 1 year ago

kartoch commented 8 years ago

For any post, if I try to insert the following code:

{% url '/index.html ' %}

If the following stacktrace:

Traceback (most recent call last):
  File "/home/kartoch/works/python/Cactus/cactus/cli.py", line 163, in <module>
    cli_entrypoint()
  File "/home/kartoch/works/python/Cactus/cactus/cli.py", line 159, in cli_entrypoint
    main(sys.argv[1:])
  File "/home/kartoch/works/python/Cactus/cactus/cli.py", line 155, in main
    ns.target(**kwargs)
  File "/home/kartoch/works/python/Cactus/cactus/cli.py", line 50, in build
    site.build()
  File "/home/kartoch/works/python/Cactus/cactus/site.py", line 243, in build
    self.plugin_manager.preBuild(self)
  File "/home/kartoch/works/python/Cactus/cactus/plugin/manager.py", line 31, in call
    _meth(*args, **kwargs)
  File "/home/kartoch/Documents/works/web/iguchi-c.lifl.fr/plugins/blog.py", line 54, in preBuild
    postContext['body'] = getNode(get_template(page.path), name="content")
  File "/home/kartoch/Documents/works/web/iguchi-c.lifl.fr/plugins/blog.py", line 23, in getNode
    return getNode(node.nodelist, context, name)
  File "/home/kartoch/Documents/works/web/iguchi-c.lifl.fr/plugins/blog.py", line 21, in getNode
    return node.render(context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/loader_tags.py", line 53, in render
    result = self.nodelist.render(context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/base.py", line 840, in render
    bit = self.render_node(node, context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/base.py", line 854, in render_node
    return node.render(context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/defaulttags.py", line 97, in render
    output = self.nodelist.render(context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/base.py", line 840, in render
    bit = self.render_node(node, context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/base.py", line 854, in render_node
    return node.render(context)
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/base.py", line 1125, in render
    return func(*resolved_args, **resolved_kwargs)
  File "/home/kartoch/works/python/Cactus/cactus/template_tags.py", line 52, in url
    site = context['__CACTUS_SITE__']
  File "/home/kartoch/opt/virtualenv-cactus/lib/python2.7/site-packages/django/template/context.py", line 56, in __getitem__
    raise KeyError(key)
KeyError: '__CACTUS_SITE__'
kartoch commented 8 years ago

If I understand well, post page context is empty, not using the 'site.context()'

blattms commented 8 years ago

@kartoch Maybe my PR #230 fixed your problem, too.

ghost commented 8 years ago

@blattms does fix it for me. Thanx!

blattms commented 8 years ago

I guess this should be closed with #230 merged.