Module: Aker::Form::LoginFormAssetProvider
- Includes:
- Rack::Utils
- Included in:
- Middleware::LoginRenderer, Middleware::LoginResponder, Middleware::LogoutResponder
- Defined in:
- lib/aker/form/login_form_asset_provider.rb
Overview
Provides HTML and CSS for login forms.
Instance Method Summary (collapse)
-
- (String) asset_root
Where to look for HTML and CSS assets.
-
- (String) login_css
Provides the CSS for the login form.
-
- (String) login_html(env, options = {})
Provides the HTML for the login form.
Instance Method Details
- (String) asset_root
Where to look for HTML and CSS assets.
This is currently hardcoded as (aker gem root)/aker/modes/middleware/form.
19 20 21 22 23 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 19 def asset_root File.(File.join(File.dirname(__FILE__), %w(.. .. ..), %w(assets aker modes middleware form))) end |
- (String) login_css
Provides the CSS for the login form.
51 52 53 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 51 def login_css File.read(File.join(asset_root, 'login.css')) end |
- (String) login_html(env, options = {})
Provides the HTML for the login form.
This method expects to find a login.html.erb ERB template in
#asset_root. The ERB template is evaluated in an environment where
a local variable named script_name is bound to the value of the
SCRIPT_NAME Rack environment variable, which is useful for CSS and
form action URL generation.
41 42 43 44 45 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 41 def login_html(env, = {}) script_name = env['SCRIPT_NAME'] template = File.read(File.join(asset_root, 'login.html.erb')) ERB.new(template).result(binding) end |