Module: Rack::Webconsole::AssetHelpers

Included in:
Assets
Defined in:
lib/rack/webconsole/asset_helpers.rb

Overview

Helper module to encapsulate the asset loading logic used by the Assets middleware.

For now, the strategy is reading the files from disk. In the future, we should come up with a somewhat more sophisticated strategy, although Rack::Webconsole is used only in development environments, where performance isn't usually a concern.

Instance Method Summary collapse

Instance Method Details

#css_codeString

Loads the CSS from a file in `/public`.

It contains the styles for the console.

Returns:

  • (String)

    the injectable CSS.



27
28
29
30
31
# File 'lib/rack/webconsole/asset_helpers.rb', line 27

def css_code
  '<style type="text/css">' <<
    asset('webconsole.css') <<
    '</style>'
end

#html_codeString

Loads the HTML from a file in `/public`.

It contains a form and the needed divs to render the console.

Returns:

  • (String)

    the injectable HTML.



18
19
20
# File 'lib/rack/webconsole/asset_helpers.rb', line 18

def html_code
  asset 'webconsole.html'
end

#js_codeString

Loads the JavaScript from a file in `/public`.

It contains the JavaScript logic of the webconsole.

Returns:

  • (String)

    the injectable JavaScript.



38
39
40
41
42
# File 'lib/rack/webconsole/asset_helpers.rb', line 38

def js_code
  '<script type="text/javascript">' <<
    asset('webconsole.js') <<
    '</script>'
end