简体   繁体   English

是否可以在web.py的模板中具有可选参数

[英]is it possible to have optional parameters in templates in web.py

Is it possible to have optional parameters in templates in web.py. 是否可以在web.py的模板中具有可选参数。 Suppose you want to pass error messages only if an error has occured, how would you go about doing it ?? 假设您只想在发生错误时传递错误消息,您将如何处理?

Templetor, the web.py template system is just Python code embedded in HTML files (with a couple limitations), so yes, you can pass optional parameters using *args and **kwargs , for example: Templetor,web.py模板系统只是嵌入在HTML文件中的Python代码 (有一些限制),因此可以,您可以使用* args和** kwargs传递可选参数,例如:

$def with(**kwargs)
$if kwargs['error']:
    <p class=error>$kwargs['error']</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM