将 HTML 添加到 Rails Gem 上的 Ruby

Adding HTML to a Ruby on Rails Gem

我不是 RoR 专家,正在尝试编写我的第一个 gem,其中包括 javascript、erb 等。这可能吗,我似乎可以找到每个教程和示例代码仅包含 ruby 代码。如果可能的话,gem 和 erb 文件的目录结构是什么样的?谢谢

你要的是engine.

Engines can be considered miniature applications that provide functionality to their host applications. A Rails application is actually just a "supercharged" engine, with the Rails::Application class inheriting a lot of its behavior from Rails::Engine.

Therefore, engines and applications can be thought of almost the same thing, just with subtle differences, as you'll see throughout this guide. Engines and applications also share a common structure.