user3295878
user3295878

Reputation: 861

Odoo check t-raw="0"

I have a template like this:

<template id="id1">
 <h1>Title</h1>
 <t t-raw="0"/>
</template>

And it is called like below:

<t t-call="id1">
 <div>Hello<div>
</t>

Or like this:

<t t-call="id1"/>

The problem is that for the second type, there's [] in the HTML. Is there a way to check if "0" has any content?

Edit: I've tried

<t t-if="0" t-raw="0"/>

And it doesn't work.

Upvotes: 3

Views: 2879

Answers (1)

Pankaj78691
Pankaj78691

Reputation: 384

if you have written in your template than whenever any template calls your template then body of the calling template is available as the raw value in variable '0'

for example your template

 <template id="id1">
     <h1>Title</h1>
     <t t-raw="0"/>
     <h2> content after calling template</h2>
 </template>

if you call like this

    <t t-call="id1">
     <div>Hello<div>
    </t>

then output will be like this

<h1>Title</h1>
 <div>Hello<div>
<h2> content after calling template</h2>

and if you call like this

     <t t-call="id1"/>
     <div>Hello<div>

then output will be like this

 <h1>Title</h1>
 <h2> content after calling template</h2>
 <div>Hello<div>

I hope this is helpful to understand the concept

Upvotes: 5

Related Questions