Skip to content

Commit bda580f

Browse files
author
Arik Kfir
committed
Support "include" operation in Jinja expressions.
1 parent c4724d5 commit bda580f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import termios
33
import tty
44
from contextlib import AbstractContextManager
5+
from pathlib import Path
56
from typing import Any, Callable
67

78
import emoji
89
from colors import *
9-
from jinja2 import Environment, Template, Undefined
10+
from jinja2 import Environment, Template, Undefined, FileSystemLoader
1011
from jinja2.exceptions import TemplateSyntaxError, UndefinedError
1112

1213

@@ -117,7 +118,7 @@ def getch() -> None:
117118

118119
def post_process(value: Any, context: dict) -> Any:
119120
def _evaluate(expr: str) -> Any:
120-
environment: Environment = Environment()
121+
environment: Environment = Environment(loader=FileSystemLoader(str(Path('.').absolute())))
121122
try:
122123
if expr.startswith('{{') and expr.endswith('}}') and expr.find('{{') == expr.rfind('{{'):
123124
# line is a single expression (only one '{{' token at the beginning, and '}}' at the end)

0 commit comments

Comments
 (0)