[Note] Missing part in Jade template

Image Credit

I have used Jade template for few projects and I really like it ! Its simplicity and indentation are key features to me compared with the other template engines. But recently, I have to build a website which can change layouts easily ( maybe by backend settings or routes ) to extend. But after trial and error and searching from the internet, I have concluded that it is one of important features lost in Jade.

Yeah, it is called “Dynamic Inheritance".

According to this issue, you can find out that this is a known issue right now in Jade because of performance issues. (when writing this article, its version is 0.31.0) Because right now in the new design of Jade, you have to define your layout to extend in children pages, it is hard ( impossible ) to change layouts dynamically like what Twig or the other templates do.

So if you really want to do that right now in Jade, there is a workaround which you have to define two pages extending different layouts and trigger the right page in controller like this :


That’s it, hope one day Jade can support this feature 😛



WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )


您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s