Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6984773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:35:34+00:00 2026-05-27T18:35:34+00:00

In my template I’m iterating over a list of elements. There are certain cases

  • 0

In my template I’m iterating over a list of elements. There are certain cases where I would like to break; or continue; in these loops. How would I do this in the play template language?

I’ve been checking the documentation here: http://www.playframework.org/documentation/1.0.2.1/tags but I can’t seem to find any information on how I would break or continue. Below are two example use cases:

#{list items:myList as:'my'}
   #{if my.name == "hello"}
     //Do something
     //I'd like to break here.
   #{/if}
#{/list}

also later on in my code I’ve got a nested list iteration like so…

#{list items:item, as:'i'}
  #{list items:anotherItem, as:'aI'}
    #{if i.name != aI.name}
      //Do Something here.
      //I'd like to continue here.
    #{/if}
  #{/list}
#{/list}

Continues

Just an additional question.. can I do things with a list like .contains();? Does anybody know of a nice guide for this language?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:35:35+00:00Added an answer on May 27, 2026 at 6:35 pm

    I think break and continue are not natively supported but you can always create your own tags to handle these cases. Take a look at http://www.playframework.org/documentation/1.1.1/templates#fasttags for details.

    The default implementation of #list is GroovyInlineTags#_list – this should give you everything you need to customise it for extra arguments.

    Personally, I would handle this logic on the server side and only pass into the view what you want to show. break is then no longer needed, and continue can be implemented as an if-else statement using the existing tags.

    As for calling methods on objects, certainly. You can use, for example, #{if myList.contains(‘whatever’)} or even put Groovy elvis operator in there for null-safety, e.g. #{if myList?.contains(‘whatever’)}

    Incidentally, which version of the Play framework are you using? 1.0.2 is pretty old now! 1.1.1 is the latest version of the 1.1 branch, and 1.2.4 is the latest version of the trunk. There’s also Play 2 (http://www.playframework.org/2.0) which is good for experimentation but you may want to hold off on using it for production for a while. Later versions of the framework have much better documentation. When running in dev mode, you can also access the version-specific documentation at http://localhost:9000/@documentation (correct the port number as necessary).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Template methods as in NOT C++ templates . So, say that you would like
template.render(current_user=current_user, thread=thread, messages=messages) Is there a dont-repeat-yourself compliant way to do whatever=whatever ? Like
template <class M, class A> class C { std::list<M> m_List; ... } Is the
TEMPLATE: <ul id=bugs-list> {% for group in groups %} <h2>{{ group.name }}</h2> <span></span> {%
template <typename T> class Stack { private: std::vector<T> elems; // elements public: Stack(); //
template <class T> class container { typedef list<T> ObjectList; public: ~container () { for
template <class T> class VectorRemake { private: T* list[]; int count; int capacity; public:
template <class T> class List { public: List(); ~List(); ... protected: template <class T>
template<typename Type> class List { public: List(void); ~List(void); ... } which inherited by template<typename
template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.