Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if 、for循环命令中无法使用‘%’取余 #374

Closed
4 tasks done
OwnerCM opened this issue Feb 21, 2023 · 4 comments
Closed
4 tasks done

if 、for循环命令中无法使用‘%’取余 #374

OwnerCM opened this issue Feb 21, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@OwnerCM
Copy link
Contributor

OwnerCM commented Feb 21, 2023

Verify steps

  • Tracker 我已经在 Issue Tracker 中找过我要提出的问题
  • Latest 我已经使用 最新源码 测试过,问题依旧存在
  • Core 这是 QianDao 框架存在的问题,并非我所使用的 QianDao早期版本(如 20210628及之前版号 等)或模板的特定问题
  • Meaningful 我提交的不是无意义的 催促更新或修复 请求

QianDao Version

20230111

Bug on OS

Linux

Bug on Platform

Docker/Linux 64位

To Reproduce

因为if、for循环系统标识中已包含%,导致判断条件不能使用‘%’计算取余数,如下:
{% if days|int % 7 == 0 %}

Describe the Bug

取余符号跟{%标识冲突

QianDao config

No response

QianDao log

<class 'TypeError'>: "unsupported operand type(s) for %: 'type' and 'int'" while evaluating 'days|int % 7 == 0 '

Expected behavior

希望可以增加‘%’取余计算逻辑

Screenshots

No response

@OwnerCM OwnerCM added the bug Something isn't working label Feb 21, 2023
@a76yyyy
Copy link
Contributor

a76yyyy commented Feb 21, 2023

使用
{% if int(days) % 7 == 0 %}

在if判断里使用int(days)来将str转换为整数

@OwnerCM
Copy link
Contributor Author

OwnerCM commented Feb 21, 2023

在if判断里使用int(days)来将str转换为整数

这种方式也使用过了,同样报错,错误如下(我感觉是因为%的关系):
41PU}MFLCS22W({D@{J C T

@a76yyyy
Copy link
Contributor

a76yyyy commented Feb 21, 2023

在if判断里使用int(days)来将str转换为整数

这种方式也使用过了,同样报错,错误如下(我感觉是因为%的关系): 41PU}MFLCS22W({D@{J C T

暂时只支持在 if API里使用 int(days), 其他地方请使用 {{days|int % 7}}

@OwnerCM
Copy link
Contributor Author

OwnerCM commented Feb 22, 2023

已经解决,谢谢王哥

@OwnerCM OwnerCM closed this as completed Feb 22, 2023
a76yyyy added a commit that referenced this issue Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants