开发者

replace only one variable in web.py templates

开发者 https://www.devze.com 2022-12-22 09:20 出处:网络
I am passing variable to template in web.py and have the same condition in some places. Like this: $if myvar==\"string1\":

I am passing variable to template in web.py and have the same condition in some places. Like this:

$if myvar=="string1":

$p开发者_StackOverflow社区assed argument1

............

$if myvar =="striung2":

$passed argument2

If say myvar is "string1" and I pass passed = "AAA" then I have AAA argument1 on my page, but the other if statements get replaced by empty string?

How to avoid that? I.e. how to leave other statements intact?


Your question is unclear. What are you trying to do? It sounds like you just need to use else:

if myvar == "string1":
  print passed
else:
  # something

But it's very hard to understand what you are asking.

0

精彩评论

暂无评论...
验证码 换一张
取 消