【问题标题】:Play! Render another template inside my template玩!在我的模板中渲染另一个模板
【发布时间】:2011-12-05 18:04:50
【问题描述】:

我正在使用Play! Framework 1.2.3、CRUD 模块和 Java

假设我有这个代码:

@Entity
public class Foo extends Model {
}

@Entity
public class Bar extends Model {
   public Foo foo;
}

Foo 类有自己的模板布局(位于 views/Foo/show.html)。这同样适用于 Bar 类:

<!-- Bars/show.html -->
#{form action:@save(object._key()), enctype:'multipart/form-data'}
        #{crud.form fields:['foo']}
        #{/crud.form}
...

但是,我想编辑 html 中的 'foo' 字段。

我发现 #{include} 是这样的:

#{include "Foos/show.html"/}

但我得到一个错误:

 NullPointerException : Cannot get property 'type' on null object.

看了这个link我试过了:

#{include "Foos/show.html" arg:'object.foo'/}

但是玩!给我错误:

unexpected token: arg

有没有人成功尝试生成 html 来更改内联字段内容?

【问题讨论】:

    标签: java templates playframework


    【解决方案1】:

    嗯,根据您发布的链接,您的代码应该是

    #{include arg:"Foos/show.html", foo:'object.foo'/}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2016-10-08
      • 2019-08-31
      相关资源
      最近更新 更多