Search code examples
htmljstl

how to use for loop inside HTML template


I have an html template which I use in marionette view . I pass a parameter in the template when I call it inside the render function . I want to add multiple div elements depending on the value of the parameter .How can I add for loop inside html template??

<div id="mainArea">
    <div data-role="view">
        <div id="scrollView" data-role="scrollView" data-stretch="true">
            <div id = 'leftArrowImage' class="leftArrowImage">
            </div>

            <div id = 'mainViewArea'></div>
            <div id = 'rightArrowImage'></div>
           
            
           /* I have passed a variable here named allWidgets. I want to add the number of divs(<div data-role="page" ></div>) equal to the length of allWidgets array. How do I do that*/ 
        </div>
    </div>
</div>


Solution

  • <link rel="stylesheet" type="text/css" href="Widgets/ReportWidget/styles/scrollLayout.css"/>
    
    <div id="mainArea">
        <div data-role="view">
            <div id="scrollView" data-role="scrollView" data-stretch="true">
                <div id = 'leftArrowImage' class="leftArrowImage">
                </div>
    
                <div id = 'mainViewArea'></div>
                <div id = 'rightArrowImage'></div>
                <%  var i;
                for i in allWidgets{ %>
                    <div data-role="page" class="pages"  >
                </div>
                }%>
            </div>
        </div>
    </div>