Phillip Schmidt
Phillip Schmidt

Reputation: 8818

Rendering a Play Framework 2 View

I'm just kind of confused as a whole when it comes to play framework. I've gotten most of everything figured out, but it seems like every day something new comes up.

Anyway, the thing of the day is this: my scala template code is showing up as plain text in my rendered document. Maybe its the wrong syntax, maybe its play 1.0 syntax, I dunno. The template looks like this:

@(model : models.Menu)

@main("Bearings") {

<div id="bearings_container">

    <div id="menu">
    <ul id="firstLevel">
    #{list items:model.items,as:'menuItem'}
        <li id="${menuItem.name}" class="firstLevel">${menuItem.name}</li>
        <ul id="${menuItem.name}- submenu">
        #{list items: menuItem.subMenu, as:'subMenuItem'}
            <li id="${subMenuItem.name}" class="secondLevel">${subMenuItem.name}</li>
            <ul id="${subMenuItem.name}- submenu">
            #{list items: subMenuItem.subMenu, as:'subSubMenuItem'}
            <li id="${subSubMenuItem.name}" class="thirdlevel">${subSubMenuItem.name}</li>
            #{/li}
            </ul>
        #{/li}
        </ul>
    #{/li}
    </ul>
    </div>
</div>
}

I'm sure it's something simple. Any ideas?

Edit: here's the controller action:

public static Result bearings()
{
    Menu menu = BuildMenu();
    return ok(views.html.bearings.render(menu));
}

And the result is what a straight HTML result of the code above would look like.

Upvotes: 0

Views: 6299

Answers (2)

Ratan Sebastian
Ratan Sebastian

Reputation: 1892

That's Play 1.0 template syntax. The template syntax in Play 2 is completely different.

To be fair the play documentation does make this confusion easy. I've found myself reading a Play 1.0 documentation page that I get to from a Google search for a while before I realize that the URL says 1.0.

Upvotes: 5

Tomasz Zabłocki
Tomasz Zabłocki

Reputation: 417

If the output looks like straight HTML I'd try checking the template referred by @main. Please provide the main template source.

Upvotes: 2

Related Questions