【发布时间】:2017-11-13 11:32:25
【问题描述】:
我的问题是:如何在 ruby 和 bundler + jekyll 中加载本地库?
我正在尝试加载一堆本地库。 例如:project_root/_plugins/fileexists.rb
我已尝试关注 https://jekyllrb.com/docs/plugins/,但该解决方案假定您有一个可以从全局 Gem 存储库安装的库。
我要加载的插件在这里https://github.com/nicnocquee/appolo/tree/master/_plugins
我在执行 'bundle exec jekyll serve' 时遇到的错误:
Dependency Error: Yikes! It looks like you don't have fileexists or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- fileexists' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
更复杂的是,我使用的是 Liquid 模板库。 (虽然这不应该是 Liquid 问题,因为我在执行 bundle exec jekyll serve 时遇到错误。我认为..)
{% file_exists {{ fb_img_default }} %}
模板的代码在这里: https://github.com/nicnocquee/appolo/blob/master/_includes/head.html#L25
我的 _config.yml 文件用于 jekyll:https://pastebin.com/SphuLcVt Gemfile:https://pastebin.com/3ptcBx5m
提前感谢您提供有关如何进行操作的建议!
库版本
捆绑--版本 捆绑器版本 1.16.0
红宝石--版本 红宝石 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
宝石--版本 2.5.2
【问题讨论】:
-
我已经更新了我的问题,但简短的回答 - 我正在使用模板语言 Liquid 来尝试使用库代码:{% file_exists {{ fb_img_default }} %}
-
根据您链接的页面,您无需执行任何操作。 “在您的站点源根目录中,创建一个
_plugins目录。将您的插件放在这里。此目录中任何以 *.rb 结尾的文件都将在 Jekyll 生成您的站点之前加载。”如果你的东西在液体模板中没有被识别,一定是它不是一个合适的插件(没有正确注册自己或其他东西) -
感谢@SergioTulentsev 您关于“根据您链接的页面,您无需执行任何操作”的想法引导我朝着正确的方向前进。谢谢你:)