You templates must live in app/views
, as usual. To render it, just use something like below.
Renderer.render(template: "message", locals: {name: "John Doe"});
<!-- app/views/message.html.erb --> | |
Hi there, <%= name %>. |
module Renderer | |
def self.render(options = {}) | |
view = View.new(ActionController::Base.view_paths) | |
view.extend(ApplicationHelper) | |
view.render(options) | |
end | |
class View < ActionView::Base | |
include Rails.application.routes.url_helpers | |
end | |
end |