跳至內容
選單
此問題已被標幟
2 回覆
11943 瀏覽次數

How can I pass variable value in Qweb when calling a function?

I have this code :

<t t-set="fname" t-value="o.firstname"/>

<t t-set="lname" t-value="o.lastname"/>

<t t-set="city" t-value="o.city"/>

<t t-set="getadd" t-value="o.get_address('Graham','Sarah','Paris')"/>

<span t-esc="getadd"/>

 

How can I pass the variables in the first three lines to the function call in line 4? I can't put a t-esc within a t-set .

頭像
捨棄
最佳答案

Hi Abdulaah,

Can you try like this.

<t t-set="fname" t-value="o.firstname"/>

<t t-set="lname" t-value="o.lastname"/>

<t t-set="city" t-value="o.city"/>

<t t-set="getadd" t-value="o.get_address(fname , lname , city)"/>

<span t-esc="getadd"/>

 

OR you can pass like this so you not need to create extra variables

 

<span t-esc="o.get_address(o.firstname,o.lastname,o.city)"/>

 

Thanks,
Harsh Dhaduk

 

頭像
捨棄
最佳答案

Maybe I do not understand something, can not you do it this way (raplace all lines by one)?:

<span t-esc="o.get_address(o.firstname,o.lastname,o.city)"/>

頭像
捨棄