Create a Twirl template that accepts a string parameter name and displays "Hello, name!" in an HTML paragraph tag.
List Rendering
Make a Twirl template that takes a List of strings and renders each string in an unordered list (<ul>). Ensure to handle an empty list gracefully by displaying a friendly message.
Form Submission Display
Develop a form in Twirl that posts a user's first and last name to a Play controller. Then, display the submitted names on a new page using another Twirl template.
Conditional Content
Design a Twirl template that accepts a Boolean value. Depending on the value, it should display different messages or HTML elements.
Nested Templates
Create a main layout template that includes a header, footer, and a placeholder for content. Then, create a child template that extends this layout and populates the content area with specific information.
Loop with Conditional
Write a Twirl template that takes a list of integers. Display each number in a list item (<li>). Highlight numbers that are divisible by 3 by making them bold.
To add a Twirl template to your Play project, create a file with the .scala.html extension in the app/views directory.
Pass data to your Twirl templates by adding parameters to the template function declaration. For example, to pass a name to your template, start the file with @(name: String).
Use Scala control structures directly in your templates for loops and conditionals.