【问题标题】:How do I use sections with three levels of inheritance如何使用具有三个继承级别的节
【发布时间】:2015-03-06 02:47:10
【问题描述】:

我在 Java 中使用 Rythm 作为我的模板引擎,我正在尝试使用具有继承的部分,但是在多次扩展模板时我被卡住了。

我想要的是从多个地方附加到一个部分。

说明:我有三个模板,它们继承如下: base.html < internal.html < main.html(主要是最具体的)

在 base.html 我定义了一个

@render(styles) {
  <link href="/ex1.css"/>
}

在 main.html 中我包含如下部分:

@section(styles) {
  @inherited()
  <link href="/ex3.css">
}

到目前为止,这工作正常。

问题:当我在 internal.html 中包含一个节块时。 (层次结构中间的模板。)

@section(styles) {
  @inherited()
  <link href="/ex2.css">
}

internal.html 部分被完全跳过。 我做错了什么还是有一个好的解决方案?

【问题讨论】:

    标签: java web template-engine rythm


    【解决方案1】:

    请在https://github.com/greenlaw110/rythm/issues 上打开一个问题。在确认并解决问题之前,请尝试使用不同的部分名称命名您的内部样式:

    @section(internal_section) {
    <link href="/ex2.css">
    }
    

    在你的base.html 中你有

    @render(styles) {
       @render(internal_section)
       <link href="/ex1.css"/>
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多