69d5182afacfd57da62ecd42955db6f9baf32c3a — Jochen Kupperschmidt 5 days ago ddd33bd
Do not attempt to extract current page value from snippets anymore

This is no longer useful as snippets are not rendered as pages anymore.
2 files changed, 1 insertions(+), 12 deletions(-)

M byceps/blueprints/site/snippet/templating.py
M byceps/util/templating.py
M byceps/blueprints/site/snippet/templating.py => byceps/blueprints/site/snippet/templating.py +1 -2
@@ 16,7 16,7 @@ from ....services.snippet.dbmodels.snippet import SnippetVersion
from ....services.snippet import service as snippet_service
from ....services.snippet.service import SnippetNotFound
from ....services.snippet.transfer.models import Scope
from ....util.templating import get_variable_value, load_template
from ....util.templating import load_template

Context = Dict[str, Any]

@@ 26,7 26,6 @@ def get_snippet_context(version: SnippetVersion) -> Context:
    """Return the snippet context to insert into the outer template."""
    template = _load_template_with_globals(version.body)

    current_page = get_variable_value(template, 'current_page')
    title = version.title
    head = _render_template(version.head) if version.head else None
    body = template.render()

M byceps/util/templating.py => byceps/util/templating.py +0 -10
@@ 50,16 50,6 @@ def create_sandboxed_environment(
    return ImmutableSandboxedEnvironment(loader=loader, autoescape=autoescape)

def get_variable_value(template: Template, name: str) -> Optional[Any]:
    """Return the named variable's value from the template, or `None` if
    the variable is not defined.
        return getattr(template.module, name)
    except AttributeError:
        return None

class SiteTemplateOverridesLoader(BaseLoader):
    """Look for site-specific template overrides."""