初始提交,未完全测试
This commit is contained in:
33
template/ext/directive/StringDirective.py
Normal file
33
template/ext/directive/StringDirective.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3.9
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
JFinal StringDirective - String Directive
|
||||
"""
|
||||
|
||||
from ...Directive import Directive
|
||||
from ...Env import Env
|
||||
from ...stat.Scope import Scope
|
||||
|
||||
class StringDirective(Directive):
|
||||
"""String directive for string operations"""
|
||||
|
||||
def exec(self, env: Env, scope: Scope, writer) -> None:
|
||||
"""
|
||||
Execute string directive
|
||||
|
||||
Args:
|
||||
env: Template environment
|
||||
scope: Execution scope
|
||||
writer: Output writer
|
||||
"""
|
||||
if self.expr_list:
|
||||
# Get string value
|
||||
string_value = self.expr_list.eval(scope)
|
||||
|
||||
if string_value is not None:
|
||||
# Output string
|
||||
if hasattr(writer, 'write'):
|
||||
writer.write(str(string_value))
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return "StringDirective()"
|
||||
Reference in New Issue
Block a user