Is there a way to break from a foreach loop in velocity?

后端 未结 1 1156
长情又很酷
长情又很酷 2021-01-07 18:24

I\'m looking for a certain condition by using foreach to iterate through a collection (of permissions). So if I find all that I need and don\'t need to loop anymore, is the

相关标签:
1条回答
  • 2021-01-07 19:06

    The latest version of Velocity (1.6) contains a statement #break

    https://velocity.apache.org/engine/1.6.2/user-guide.html#Loops

    ## list first 5 customers only
    #foreach( $customer in $customerList )
        #if( $velocityCount > 5 )
            #break
        #end
        $customer.Name
    #end
    
    0 讨论(0)
提交回复
热议问题