nodejs玉条件扩展 [英] nodejs jade conditional extend

查看:141
本文介绍了nodejs玉条件扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的玉页扩展不同的布局,这取决于一个条件。所以我的代码如下所示:

I would like to make my Jade page extend different layouts, depending on a condition. So my code looks like this:

if myConditionVariable
  extends layout1
else
  extends layout2  
block content
  p here goes my content!

现在这不行。似乎只有最后定义的扩展将被尊重,无论条件如何。我还尝试动态定义模板名称,例如

Now this does not work. It seems as if only the last defined extends will be respected, regardless of the conditions. I also tried dynamically defining the templatename, such as

extends myLayoutNameVariable

并以不同的方式设置myLayoutNameVariable(表达动态帮助函数,将其设置为var,local var etc ...)

and set the myLayoutNameVariable in different manners (express dynamic helper function, set it as var, local var etc...)

有条件布局还有其他解决方案吗?有人可以告诉我我做错了什么?

Is there any other solution for conditional layouts or can someone tell me what i am doing wrong?

干杯,simon

推荐答案

这似乎是一个仍然在 github上打开的问题

这篇关于nodejs玉条件扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆