Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
40240 Lượt xem

Hi, 

I want to write a simple comparison expression in qweb (if age<16 then do something). But unfortunately, i can't use a smaller symbol "<".

 <t t-if="student.age < 16">
do something .......
</t>


Please help!!!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

XML has just five special characters, all they has corresponding codes:

 &lt; (<), &amp; (&), &gt; (>), &quot; ("), and &apos; (').

you've to use &lt; xml code of <, from above list:

<t t-if="student.age &lt; 16">
do something .......
</t>

Ảnh đại diện
Huỷ bỏ

Quite strange though, I can use the normal characters without encoding them. I know its best practice to encode so but still strange that this doesn't work for thavorac.

maybe it works without encoding in some cases. I tried once to use in odoo domain statement in XML a & symbol as AND operator, it doesn't worked, then reverted back to encoded version: & amp ; and it started working. since I'm using only encoded versions of these 5 characters, to be sure...

Guess I'll always use encoding from now on then!

You may need to use &amp;lt; instead of &lt;

A similar expression for other special characters.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1963
1
thg 5 25
2050
1
thg 4 25
2484
1
thg 2 25
1756
0
thg 10 24
1495