初始提交,未完全测试
This commit is contained in:
36
template/ext/directive/CallDirective.py
Normal file
36
template/ext/directive/CallDirective.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3.9
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
JFinal CallDirective - Call Directive
|
||||
"""
|
||||
|
||||
from ...Directive import Directive
|
||||
from ...Env import Env
|
||||
from ...stat.Scope import Scope
|
||||
|
||||
class CallDirective(Directive):
|
||||
"""Call directive for calling template functions"""
|
||||
|
||||
def exec(self, env: Env, scope: Scope, writer) -> None:
|
||||
"""
|
||||
Execute call directive
|
||||
|
||||
Args:
|
||||
env: Template environment
|
||||
scope: Execution scope
|
||||
writer: Output writer
|
||||
"""
|
||||
if self.expr_list:
|
||||
# Get function name
|
||||
function_name = self.expr_list.eval(scope)
|
||||
|
||||
if function_name:
|
||||
# Get function from env
|
||||
func = env.get_function(str(function_name))
|
||||
|
||||
if func:
|
||||
# Call function
|
||||
func.exec(env, scope, writer)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return "CallDirective()"
|
||||
Reference in New Issue
Block a user