Module: Briefly::Rails::View

Defined in:
lib/briefly/rails/view.rb

Overview

Helpers, routes and rendering outside a controller.

App = Briefly.define { use Briefly::Rails::View }
App.h             # => ApplicationController.helpers
App.render(...)   # => ApplicationController.renderer.render(...)

Inside this file the framework is always ::Rails / ::ApplicationController — the bare names would resolve to the parent module.

Class Method Summary collapse

Class Method Details

.install(builder) ⇒ Briefly::Builder

Parameters:

Returns:



18
19
20
21
22
23
24
# File 'lib/briefly/rails/view.rb', line 18

def install(builder)
  builder.shortcut(:helpers, :h) { ::ApplicationController.helpers }
  builder.shortcut(:routes, :r) { ::Rails.application.routes.url_helpers }
  builder.shortcut(:renderer) { ::ApplicationController.renderer }
  builder.shortcut(:render) { |*args, **kwargs, &blk| renderer.render(*args, **kwargs, &blk) }
  builder
end