模板帮助中的把手和html-在行中循环显示内容

时间:2018-07-26 00:59:26

标签: html handlebars.js

当我的行具有左右单元格时,如何使文章以html动态呈现时出现了问题。下面是我的代码。当我这样做时,第一篇文章(索引中的第0条)在第1行中同时放在左和右位置。如果我有8条文章,我希望有4行,每行有两篇不同的文章,但我却得到了8条同一篇文章的左右行。

enter image description here

<!--=================-Rows with 2 items in each section=================-->
<table width="640" align="center" class="em_main_table em_fixed" border="0" cellspacing="0" cellpadding="0">
        {{#each sections}}
        {{#ifEqual this.sectionId "section2-articles"}}
        {{#if this.items.[0]}}
        {{#each items}}
        {{#ifEqual this.contentType "article"}}
    <tr>
        <td valign="top" align="center"  class="em_pad">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                    <td valign="top">
                        <table width="276" class="em_wrapper" border="0" cellspacing="0" cellpadding="0" align="left" >
                            <tr>
                                <td align="center" valign="top" class="em_top_5" >
                                    <a href="{{url}}" target="_blank" class="em_text_none" >
                                        <img src="{{imageUrl}}?W=276" width="276" height="175"  class="em_img3" border="0" alt=""/>
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td height="5" class="em_height em_f_h_zero">&nbsp;</td>
                            </tr>
                            <tr>
                                <td align="left" class="em_black1 em_heada" >
                                    <a href="{{url}}" target="_blank">{{title}}</a>
                                </td>
                            </tr>   
                        </table>
                        <table width="276" class="em_wrapper" border="0" cellspacing="0" cellpadding="0" align="right" >
                            <tr>
                                <td align="center" valign="top"  class="em_top em_top_5" >
                                    <a href="{{url}}" target="_blank" class="em_text_none" >
                                        <img src="{{imageUrl}}?W=276" width="276" height="175"  class="em_img3" border="0" alt=""/>
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td height="5" class="em_height em_f_h_zero">&nbsp;</td>
                            </tr>
                            <tr>
                                <td align="left" class="em_black1 em_heada" ><a href="{{url}}" target="_blank">{{title}}</a></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="30"  class="em_height em_f_h_zero">&nbsp;</td>
    </tr>
         {{/ifEqual}}              
         {{/each}}
         {{/if}}
         {{/ifEqual}}
         {{/each}} 
</table>
<!--=================-Rows with 2 items in each section=================-->

1 个答案:

答案 0 :(得分:0)

缩进代码是正确读取代码的唯一方法。 使用div和CSS句柄而不是表来完成这项工作。