【问题标题】:Using Leaf, the else condition isn't properly executed though the if one is使用 Leaf,else 条件没有正确执行,尽管 if 是
【发布时间】:2019-05-26 06:52:23
【问题描述】:

我有一个简单的 Leaf 模板,我想在其中显示 Hello World。

#if(false) {
<title> All hail Apodron.</title>
} #else {
<title> Hello World </title>
}

页面没有标题并显示为:

#else {Helloward}

但是,如果我将其更改为:

#if(true) {
<title> All hail Apodron.</title>
} #else {
<title> Hello World </title>
}

然后标题确实显示,但页面仍然显示为:

#else {Helloward}

我也尝试了各种语法,比如:

##else { <title> Hello World </title> }#else() { <title> Hello World </title> } 甚至##else() { <title> Hello World </title> }

这似乎很基本,我相信我遵循了documentation

【问题讨论】:

  • 蒸汽控制台是否提供任何有用的信息?
  • 什么都没有:Server starting on http://localhost:8080。有没有更详细的模式?

标签: if-statement vapor leaf


【解决方案1】:

看起来您的问题是 Leaf 期待 else,但正在使用 #else。因此,将您的模板更改为此应该可以解决它:

#if(false) {
  <title> All hail Apodron.</title>
} else {
  <title> Hello World </title>
}

这里是相关的documentation

【讨论】:

    猜你喜欢
    • 2021-12-21
    • 2012-06-08
    • 1970-01-01
    • 2020-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    相关资源
    最近更新 更多