Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无论skip_render如何设置都无法跳过source目录下的某个js文件目录,生成出错 #1333

Closed
blueyi opened this issue Jun 11, 2015 · 13 comments · May be fixed by Bhanditz/hexo#7, one3chens/hexo#13, feicc/hexo#12, mdno/hexo#14 or neolivz/hexo#15
Labels
bug Something isn't working skip-render

Comments

@blueyi
Copy link

blueyi commented Jun 11, 2015

hexo 3.x版本,具体版本号下面贴出,将这个代码https:/jserme/mahua放进source目录后,无论skip_render参数如何设置,无论系统是linux还是windows,执行hexo g的时候都会出现如下错误:

E:\blog>hexo g
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/do
cs/troubleshooting.html
Template render error: expected variable end
    at Error.exports.TemplateError (E:\blog\node_modules\hexo\node_modules\nunju
cks\src\lib.js:51:19)
    at Object.extend.fail (E:\blog\node_modules\hexo\node_modules\nunjucks\src\p
arser.js:64:15)
    at Object.extend.advanceAfterVariableEnd (E:\blog\node_modules\hexo\node_mod
ules\nunjucks\src\parser.js:133:18)
    at Object.extend.parseNodes (E:\blog\node_modules\hexo\node_modules\nunjucks
\src\parser.js:1159:22)
    at Object.extend.parseAsRoot (E:\blog\node_modules\hexo\node_modules\nunjuck
s\src\parser.js:1177:42)
    at Object.module.exports.parse (E:\blog\node_modules\hexo\node_modules\nunju
cks\src\parser.js:1199:18)
    at Object.module.exports.compile (E:\blog\node_modules\hexo\node_modules\nun
jucks\src\compiler.js:1118:48)
    at Obj.extend._compile (E:\blog\node_modules\hexo\node_modules\nunjucks\src\
environment.js:444:35)
    at Obj.extend.compile (E:\blog\node_modules\hexo\node_modules\nunjucks\src\e
nvironment.js:433:18)
    at null.<anonymous> (E:\blog\node_modules\hexo\node_modules\nunjucks\src\env
ironment.js:378:22)
    at Object.exports.withPrettyErrors (E:\blog\node_modules\hexo\node_modules\n
unjucks\src\lib.js:24:16)
    at Obj.extend.render (E:\blog\node_modules\hexo\node_modules\nunjucks\src\en
vironment.js:374:20)
    at Obj.extend.renderString (E:\blog\node_modules\hexo\node_modules\nunjucks\
src\environment.js:261:21)
    at E:\blog\node_modules\hexo\lib\extend\tag.js:56:9
    at tryCatcher (E:\blog\node_modules\hexo\node_modules\bluebird\js\main\util.
js:24:31)
    at Promise._resolveFromResolver (E:\blog\node_modules\hexo\node_modules\blue
bird\js\main\promise.js:427:31)
    at new Promise (E:\blog\node_modules\hexo\node_modules\bluebird\js\main\prom
ise.js:53:37)
    at Tag.render (E:\blog\node_modules\hexo\lib\extend\tag.js:55:10)
    at E:\blog\node_modules\hexo\lib\hexo\post.js:320:16
    at tryCatcher (E:\blog\node_modules\hexo\node_modules\bluebird\js\main\util.
js:24:31)
    at Promise._settlePromiseFromHandler (E:\blog\node_modules\hexo\node_modules
\bluebird\js\main\promise.js:454:31)
    at Promise._settlePromiseAt (E:\blog\node_modules\hexo\node_modules\bluebird
\js\main\promise.js:530:18)
    at Async._drainQueue (E:\blog\node_modules\hexo\node_modules\bluebird\js\mai
n\async.js:182:12)
    at Async._drainQueues (E:\blog\node_modules\hexo\node_modules\bluebird\js\ma
in\async.js:187:10)
    at Immediate.Async.drainQueues [as _onImmediate] (E:\blog\node_modules\hexo\
node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:358:17)

hexo 版本号:

E:\blog>hexo --version
hexo: 3.0.1
os: Windows_NT 6.3.9600 win32 x64
http_parser: 2.3
node: 0.12.4
v8: 3.28.71.19
uv: 1.5.0
zlib: 1.2.8
modules: 14
openssl: 1.0.1m

具体情况及讨论内容见http://xuanwo.org/2014/08/14/hexo-usual-problem/#comment-2073484518

之前使用hexo 2.8没有遇到这个问题,谢谢

@Xuanwo Xuanwo mentioned this issue Jun 11, 2015
8 tasks
@Xuanwo
Copy link
Contributor

Xuanwo commented Jun 11, 2015

  it('skip render', function(){
    hexo.config.skip_render = 'lab/**/*.js';

    return Page.insert({
      source: 'lab/assets/jquery.min.js',
      path: 'lab/assets/jquery.min.js',
      layout: false,
      raw: 'jquery raw'
    }).then(function(page){
      return generator(locals()).then(function(data){
        data.should.eql([
          {path: page.source, data: page.raw}
        ]);

        hexo.config.skip_render = [];
        return page.remove();
      });
    });
  });

  it('skip render - multiple rules', function(){
    hexo.config.skip_render = ['lab/**/*.js'];

    return Page.insert({
      source: 'lab/assets/jquery.min.js',
      path: 'lab/assets/jquery.min.js',
      layout: false,
      raw: 'jquery raw'
    }).then(function(page){
      return generator(locals()).then(function(data){
        data.should.eql([
          {path: page.source, data: page.raw}
        ]);

        hexo.config.skip_render = [];
        return page.remove();
      });
    });
  });

  it('skip render - don\'t replace extension name', function(){
    hexo.config.skip_render = 'README.md';

    return Page.insert({
      source: 'README.md',
      path: 'README.html',
      layout: 'page',
      raw: 'readme raw'
    }).then(function(page){
      return generator(locals()).then(function(data){
        data.should.eql([
          {path: page.source, data: page.raw}
        ]);

        hexo.config.skip_render = [];
        return page.remove();
      });
    });
  });

我去源码翻了好久,发现了这些,我在想,是不是需要指定后缀名?以及在输入多个目录的时候,我们是不是要使用js的数组形式输入?我来验证一下。

@Xuanwo
Copy link
Contributor

Xuanwo commented Jun 11, 2015

后来进行测试的结果是:
将两个子目录移除后,mahua/*可以跳过所有文件;而一旦有了子目录,就会直接报错。

结论不正确,以下一楼为准。

@Xuanwo
Copy link
Contributor

Xuanwo commented Jun 11, 2015

呼- -,终于测试完了,结果如下:

  • 使用[mahua/*, mahua/**/*]这个组合可以跳过mahua目录下所有文件以及子目录内的文档(两层)
  • 导致生成失败的是一个特别大的js文件,worker-xquery.js,1012KB,删掉这货之后就成功了。

可以得出两个结论:

  • skip_render还是挺好用的= =
  • 这可能是nunjucks的一个BUG,不能处理大号的js文件= =?

@daifee
Copy link

daifee commented Aug 31, 2015

刚遇到这问题,好像是nunjucks解析js文件报错。 希望有这么一个功能,在配置里自定义目录,将这些目录直接copy过去,不做任何处理。

@Xuanwo
Copy link
Contributor

Xuanwo commented Aug 31, 2015

据说下个版本会有这个方面的计划

@stiekel
Copy link

stiekel commented Sep 5, 2015

谢谢 @Xuanwo ,我用你的方法配置 skip_render 成功了。

@agileago
Copy link

agileago commented Sep 8, 2015

谢谢 @Xuanwo ,搞定了

@Xuanwo Xuanwo closed this as completed Sep 8, 2015
@blueyi
Copy link
Author

blueyi commented Sep 10, 2015

已经解决了吗? @Xuanwo

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 10, 2015

并没有,等Hexo 4.0吧

@qiuwei
Copy link

qiuwei commented Jan 11, 2016

#1705 seems to be related to this bug.

@lucien925
Copy link

@Xuanwo 我发[mahua/*, mahua/**/*]这种组合好像过滤不了二级目录下的所有文档,需要加上文件后缀,比如[mahua/*, mahua/**/*.html]。 还有,建议修改后发布时用hexo clean清下缓存。

@blueyi
Copy link
Author

blueyi commented Mar 27, 2016

@summerGreenTea 这个问题好像确实挺麻烦,我最近把hexo以及所需要的插件都升级到了最新版本后,使用 @Xuanwo 提供的方式就好用了,你可以试试,是不是太久没有升级过hexo

@yue4u
Copy link

yue4u commented Jan 29, 2018

@Xuanwo vue webpack生成的某个小东西想放子域名 本地怎么都正常 hexo上就是不对,skip_render中用[xxx/,xxx/**/]完全解决了我的问题。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment