Use of #if, #elseif ,#end,#foreach, #if nesting

 

Use foreach alone:

#foreach($tableDO in ${tableList})

#end

 

 

Use #if alone:

#if (a=='0')

      i am number 0

#end

 

 

Use #if with #else:

#if(a=='0')

    i am number 0

#else

    I am not the number 0

#end

 

 

#if , #elseif and #else are used together:

#if(a=='0')

    i am number 0

#elseif(a=='1')

    I am number 1

#else (a=='2')

    I am number 2

#end

 

 

 

Two #if nested:

#if()

     #if()

     #else

     #end

#end

 

Also supports nested #if within #foreach;

 

Case:

 

<table class="table table-striped table-hover table-bordered" id="sample_editable_1">

<thead>

<tr>

 

<th>Confirmed by</th>

 

<th>Status</th>

 

<th>Action</th>

 

</tr>

 

</thead>

 

<tbody>

#foreach($transferRecordTableDO in ${transferRecordTableList})

<tr>

 

<th>$!{transferRecordTableDO.confirmUser}</th>

#if ($!{transferRecordTableDO.status}=='0')

<th>Unprocessed</th>

#if(($!{transferRecordTableDO.createUser})==($!{loginName}))

<th>

<button type="" class="btn gray start" disabled="disabled">

<span>Confirm button disabled</span>

</button>

</th>

#else

<th>

<button type="button" class="btn blue start">

<span>Confirm button is OK</span>

</button>

</th>

#end

#elseif ($!{transferRecordTableDO.status}=='1')

<th>Confirmed (no confirmation button displayed)</th>

<th></th>

#else ($!{transferRecordTableDO.status}=='2')

<th>Obsolete (does not show confirmation button)</th>

<th></th>

#end

</tr>

#end

 

</tbody>

 

</table>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326021518&siteId=291194637