Nanoc规则文件不处理我的JavaScript目录

时间:2014-09-28 22:07:51

标签: javascript nanoc

我的nanoc内容目录结构:

assets -> (css, images, files)
js
partials
[*.textile source files]

从我的规则文件中提取:

compile '/js/*/' do
    # don’t filter or layout
end
.
.
.
route '/js/*/' do 
  item.identifier.chop + '.' + @item[:extension].to_s
end

命令行结果:

Message:

RuntimeError: Found 2 content files for content/js/bootstrap; expected 0 or 1

Compilation stack:

  (empty)

Stack trace:

  0. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/data_sources/filesystem.rb:168:in `block in all_split_files_in'
  1. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/data_sources/filesystem.rb:158:in `each_pair'
  2. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/data_sources/filesystem.rb:158:in `all_split_files_in'
  3. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/data_sources/filesystem.rb:86:in `load_objects'
  4. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/data_sources/filesystem.rb:45:in `items'
  5. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/base/source_data/site.rb:334:in `block in load_items'
  6. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/base/source_data/site.rb:333:in `each'
  7. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/base/source_data/site.rb:333:in `load_items'
  8. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/base/source_data/site.rb:244:in `load'
  9. /home/tomc/.rvm/gems/ruby-2.1.1/gems/nanoc-3.7.1/lib/nanoc/base/source_data/site.rb:128:in `layouts'
  ... 27 more lines omitted. See full crash log for details.

我咨询了How add own javascript file to nanoc?。我似乎正确地设置了,但我的结果却说不然。

我看不出错误。有人有主意吗?

1 个答案:

答案 0 :(得分:1)

由于将输入文件名映射到输出路径的方式,Nanoc要求content下每个文件的基本名称(即文件名少扩展名)是唯一的。从Nanoc的角度来看,你给它两个共享基本名称bootstrap的文件,因此不能有唯一的输出路径,所以它会给你这个错误。

因为你真正想要的是逐字地将Nanoc复制到你网站的这一部分(第三方JavaScript文件),所以最好将这些文件完全移出content树并设置从中加载静态数据源。然后Nanoc将简单地复制文件,而不试图处理或重命名它们。 Nanoc网站上的"Troubleshooting"页面有关于如何执行此操作的说明;请参阅"Error: “Found 3 content files for X; expected 0 or 1”下的“解决方案#2”。