Breaking a list using data-sly-list to close and re-open ul tag



I want to use sightly data-sly-test to "split" a list, but when I try to close/re-open the <ul> using a condition, the html doesn't get added in the correct place... This is essentially the code I am trying to render (simplified for demo purposes):

<sly data-sly-list.levelOne="${navigationObject.navigationBean.navList}">

<li class="nav-item">

code that repeats for each Nav Item


<sly data-sly-test="${condition}">


                <ul class="navbar-nav logo-containter-sly">


                         content to be placed in between li items on condition



                <ul class="navbar-nav">



If I leave like this, the code finished looping through the list before it includes the code in the data-sly-test. If I remove the </ul> it includes the code in the correct place (after the li where the condition is true, but before the next li).

Is there a reason this is occurring? is there a way around it??