2016-04-27 52 views
4

在这里遇到一个奇怪的问题。我有一个非常基本的玉/哈巴狗包括回事:包括帕格文件导致错误,但玉器正常工作

extends base.pug 

block vars 
    - var title = 'Home' 

block body 
    header 
     include ./includes/header.pug 

快速注意,只使用扩展基座(不包括扩展名)是行不通的。但是,这包括提供了以下错误:

TypeError: Cannot read property 'replace' of undefined 
    at before (/var/node/website/node_modules/pug-linker/index.js:104:48) 
    at walkAST (/var/node/website/node_modules/pug-walk/index.js:13:26) 
    at /var/node/website/node_modules/pug-walk/index.js:21:16 
    at Array.map (native) 
    at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29) 
    at walkAST (/var/node/website/node_modules/pug-walk/index.js:33:21) 
    at /var/node/website/node_modules/pug-walk/index.js:21:16 
    at Array.map (native) 
    at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29) 
    at /var/node/website/node_modules/pug-walk/index.js:21:16 
    at Array.map (native) 
    at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29) 
    at applyIncludes (/var/node/website/node_modules/pug-linker/index.js:102:10) 
    at link (/var/node/website/node_modules/pug-linker/index.js:21:9) 
    at compileBody (/var/node/website/node_modules/pug/lib/index.js:84:11) 
    at Object.exports.compile (/var/node/website/node_modules/pug/lib/index.js:164:16) 

但是改变,为:

extends base.pug 

block vars 
    - var title = 'Home' 

block body 
    header 
     include ./includes/header.jade 

工作完全正常。 header.jade和header.pug的内容完全相同,所以我在这里有点困惑。一些帮助将不胜感激。

感谢,

PS:搜索并显示:https://github.com/pugjs/pug-linker/issues/13 - 似乎是一个错误,但不知道如何这可能是。

+1

这适用于我现在。如果您仍然遇到问题,请查看https://github.com/pugjs/pug/issues/2305,看看它是否与此相关。 –

回答

4

所以它看起来像帕格是不是真的准备黄金时间!期待是什么时候,但用玉代替帕格解决了这个问题,只需将所有内容重新命名为.jade即可。

0

从Jade到Pug的变化之一是你不能插入变量了。您曾经能够(并鼓励)在另一个字符串中使用#{something},但现在鼓励您使用常规JavaScript变量。

例如,该

a(href="#{link}") 
a(href='before#{link}after') 

现在应该成为

a(href=link) 
a(href=`before${link}after`) //(on Node.js/io.js ≥ 1.0.0) 
a(href='before' + link + 'after') //(everywhere) 

来源:跟踪issue有重大更改。

相关问题