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 8717727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:21:57+00:00 2026-06-13T06:21:57+00:00

I am new to Play Framework and still trying to wrap my head around

  • 0

I am new to Play Framework and still trying to wrap my head around some things with the new Scala template engine.

Let’s say I have the following package structure:

app/
app/controllers/Items.scala
app/models/Item.scala
app/views/layouts/page.scala.html
app/views/item/show.scala.html
app/views/item/details.scala.html  //partial

And this is my item/show template:

    @(item: Item, form: Form[Item])(implicit flash: Flash)
    @layout.page() {
        @*want to include details partial, wont work due to item param*@
        @item.details(item)
    }

Since including another template (e.g. including item/details above) is the exact same syntax as accessing a template parameter (e.g. item above), obviously this existing naming convention won’t work without something changing.

I know I can rename my “app.views.item” package to “app.views.items”, and rely on singular/plural forms to differentiate the view from the param name, but this does not seem like a very straightforward solution. Also what if I really want the parameter name to be the same as the view package?

One idea I have is to prepend all my views with an extra top level package:

 app/views/views/item/details.scala.html

So the include syntax would be @views.item.details(), but again this is obviously a hack.

What is a good way to avoid this issue? How can I better organize my code to avoid such naming collisions?

Most other template engines use operations like “include” or “render” to specify a partial include. I don’t mean to offend anyone here, but is the Play Scala template engine syntax so terse that it actually dictates the organization of code?

  • 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-06-13T06:21:58+00:00Added an answer on June 13, 2026 at 6:21 am

    3 solutions:

    First

    Typpicaly for partial templates you should use tags as described in the docs, where app/views/tags folder is a base:

    file: app/views/tags/product.scala.html

    in the templates (no initial import required in the parent view full syntax will allow you to avoid name-clash: @tags.packageName.tagName()):

    <div id="container">
        @tags.product(item)
    </div>
    

    Of course in your case you can also use packages in the base folder

    file: app/views/tags/item/product.scala.html

    <div id="container">
        @tags.item.product(item)
    </div>
    

    I’m pretty sure that’ll solve your problem.

    Second

    To avoid clash without changing package’s name you can just rename the item in your view, also I recommend do not use a form name for the Form[T] as it can conflict with helpers:

    @(existingItem: Item, existingItemForm: Form[Item])(implicit flash: Flash)
    @layout.page() {
        @item.details(existingItem)
    }
    

    Third

    If you’ll fill your Form[Item] before passing to the view with given Item object, you don’t need to pass both, as most probably you can get data from the form:

    @(itemForm: Form[Item])(implicit flash: Flash)
    @layout.page() {
        <div>Name of item is: @itemForm("name").value (this is a replacemnet for @@existingItem.name </div>
        @item.details(itemForm)
    }
    

    Of course in you product.scala.html you’ll need to change the @(item: Item) param to @(itemForm: Form[Item])

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

Sidebar

Related Questions

I'm new to Play framework. I'm trying to configure MySQL database as a datasource
I'm new to the Entities Framework, and am just starting to play around with
I´m new to Play and Scala world, so I´m needing some help to figure
I am new to Scala, trying to integrate some existing Java code with Scala-specific
I am pretty new to Scala and Play Framework and I never saw the
New to Play! Framework and web development in general, I'm trying to do a
I am new to play framework so please bear with me. Can some one
I'm new in play framework and I'm trying to do a simple post to
I've been asking and investigating around about the new Play Framework 2.0. It seems
I am brand new to the Play framework, but I am trying to use

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.