初始提交,未完全测试

This commit is contained in:
2026-02-27 14:37:10 +08:00
parent 76c0f469be
commit e270f02073
68 changed files with 5886 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3.9
# -*- coding: utf-8 -*-
"""
JFinal Output - Output Directive
"""
from .Stat import Stat
from ..Scope import Scope
from ...Env import Env
from ...expr.ast import ExprList
class Output(Stat):
"""Output directive for template expressions"""
def __init__(self, expr_list: ExprList):
"""
Initialize output directive
Args:
expr_list: Expression list to evaluate
"""
self._expr_list = expr_list
def exec(self, env: Env, scope: Scope, writer) -> None:
"""
Execute output directive
Args:
env: Template environment
scope: Execution scope
writer: Output writer
"""
if self._expr_list:
result = self._expr_list.eval(scope)
if result is not None:
if hasattr(writer, 'write'):
writer.write(str(result))
def __repr__(self) -> str:
return f"Output({self._expr_list})"