Use SandboxedEnvironment
This commit is contained in:
parent
96076c69ac
commit
2fa96babde
1 changed files with 3 additions and 12 deletions
|
@ -7,13 +7,8 @@ from dataclasses import dataclass
|
|||
from pathlib import Path
|
||||
from typing import Any, Self, Sequence
|
||||
|
||||
from jinja2 import (
|
||||
ChoiceLoader,
|
||||
Environment,
|
||||
FileSystemLoader,
|
||||
PackageLoader,
|
||||
StrictUndefined,
|
||||
)
|
||||
from jinja2 import ChoiceLoader, FileSystemLoader, PackageLoader, StrictUndefined
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
|
||||
from hexdoc.hexcasting.hex_book import HexContext
|
||||
from hexdoc.minecraft.i18n import I18n
|
||||
|
@ -25,9 +20,6 @@ from hexdoc.utils.resource_loader import ModResourceLoader
|
|||
|
||||
from .jinja_extensions import IncludeRawExtension, hexdoc_block, hexdoc_wrap
|
||||
|
||||
# TODO: enable
|
||||
# from jinja2.sandbox import SandboxedEnvironment
|
||||
|
||||
|
||||
def strip_empty_lines(text: str) -> str:
|
||||
return "\n".join(s for s in text.splitlines() if s.strip())
|
||||
|
@ -105,8 +97,7 @@ def main(args: Args | None = None) -> None:
|
|||
)
|
||||
|
||||
# set up Jinja environment
|
||||
# TODO: SandboxedEnvironment
|
||||
env = Environment(
|
||||
env = SandboxedEnvironment(
|
||||
# search order: template_dirs, template_packages, built-in hexdoc templates
|
||||
loader=ChoiceLoader(
|
||||
[FileSystemLoader(props.template_dirs)]
|
||||
|
|
Loading…
Reference in a new issue