2

我可以在我的 gem 中使用 Haml 模板,而不在应用程序 Gemfile gem 'haml'中写入吗?

我在 my_gem.gemspec 文件中放入了这一行:

s.add_runtime_dependency "haml", "~> 3.0"

我将这一行放入 my_gem 文件夹的 Gemfile 中:

gem 'haml', '~> 3.0'

我这样做:bundle, and Haml install at this moment ,但它不起作用,我有

Template is missing
Missing template layouts/my_gem with {:handlers=>[:erb, :builder, :coffee] }

仅当我在应用程序 Gemfile 中复制时

gem 'haml', '~> 3.0'

它工作正常。

我可以将 Haml 与我的 gem 一起使用而不复制到 Gemfile 中吗?

4

1 回答 1

2

任何应用程序(引擎)都应该需要所有需要的 gem,例如对我来说:

require "haml"

require "the_role/hash"
require "the_role/engine"
require "the_role/version"
require "the_role/the_class_exists"

module TheRole
  # some code here
end
于 2011-10-31T15:40:12.857 回答