简体   繁体   English

渲染Play Framework 2视图

[英]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. 无论如何,今天的事情是这样的:我的scala模板代码在我呈现的文档中显示为纯文本。 Maybe its the wrong syntax, maybe its play 1.0 syntax, I dunno. 我不知道这可能是错误的语法,也可能是其播放1.0语法。 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. 结果就是上面代码的纯HTML结果将是什么样子。

That's Play 1.0 template syntax . 这就是Play 1.0模板语法 The template syntax in Play 2 is completely different . 播放2中的模板语法完全不同

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. 我发现自己正在阅读Play 1.0文档页面,这是我从Google搜索中找到的一段时间,然后才意识到URL表示1.0。

If the output looks like straight HTML I'd try checking the template referred by @main . 如果输出看起来像@main HTML,我将尝试检查@main引用的模板。 Please provide the main template source. 请提供main模板来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM