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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:35:38+00:00 2026-06-16T16:35:38+00:00

Using Play 2 I am realising a simple REST API, the output is plain

  • 0

Using Play 2 I am realising a simple REST API, the output is plain text. My template looks like this:

@(items: Map[String,String]) 
@for((key, value) <- items) {
@value
@key
}

In the controller:

return ok(views.html.bla.render(itemsMap)).as("text/plain");

This gives the following output:

(empty line)
(empty line)
value
key
(empty line)
value
key

I want to get rid of the first 2 empty lines – is that possible?

Putting the for in the first line removes one of the empty lines at the top, however one still remains and for in the first line makes the template hard to read ): Thanks for any hint!

  • 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-16T16:35:39+00:00Added an answer on June 16, 2026 at 4:35 pm

    First off, if you use plain text, you should use txt templates (bla.scala.txt). They also automatically set text/plain; charset=utf-8 content type.

    To trim the content, you can return the rendered content directly:

    return ok(views.txt.bla.render(itemsMap).body().trim());
    

    In case you want to render HTML content you’d need to change this manually:

    return ok(views.html.ble.render().body().trim()).as("text/html; charset=utf-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using play framework 1.2.4 with scala. I have few play jobs that looks like
Using Play! 1.2.4, Scala, and Squeryl with Postgres Performing a simple DB insert like
Using Play Framework, you can do something like this: public static void mymethod() {
I`m using Play! Framework 2.0 and I'm new in this framework. How can I
Using Play Framework 2 I've noticed the rendered Scala HTML templates don't like indented
Using Play Framework 2.0.4, I'd like to define my static content URLS differently regarding
I'm using play framework version 1.2.5 and I would like to retrieve all the
How can one create global, custom looks for their 404/505 error pages using Play?
Using Play 2.1-RC1 I can't write simple test. Here's the action code: def echoTestTagFromXml
Using Play! Framework 2.0.2, when I add several items from my java project to

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.