TemplateSv¶
-
class
clink.service.
TemplateSv
(app_conf, auth_conf)[source]¶ Simple template engine
Parameters:
Example¶
from clink.service import TemplateSv
from clink.type import AppConf, AuthConf
app_conf = AppConf('dead-book', 'Hell Corporation', '1st Hell Street')
root_pwd = 'root-pwd'
root_email = 'root@email.com'
root_email_pwd = 'root-email-pwd'
root_email_server = 'smtp.email.com'
root_email_server_port = 587
auth_conf = AuthConf(
root_pwd, root_email, root_email_pwd, root_email_server,
root_email_server_port, 'jwt-key'
)
template_sv = TemplateSv(app_conf, auth_conf)
report_tpl = (
'REPORT: MOTOCYCLE SPEC\n'
'AUTHOR: $author\n\n'
'Name : $name\n'
'Price : $price\n'
'Color : $color\n'
'Power : $power'
)
values = {
'author': 'Johnny Blaze',
'name': 'Hell Cycle',
'price': 'Not for Sale',
'color': 'Black - Red Fire',
'power': 'Unlimited'
}
report = template_sv.build_str(report_tpl, values)
print(report)
Testing¶
$ python template_sv.py
REPORT: MOTOCYCLE SPEC
AUTHOR: Johnny Blaze
Name : Hell Cycle
Price : Not for Sale
Color : Black - Red Fire
Power : Unlimit