Module: Aker::Form::LoginFormAssetProvider
- Includes:
- Rack::ConfigurationHelper, Rack::Utils
- Defined in:
- lib/aker/form/login_form_asset_provider.rb
Overview
Provides HTML and CSS for login forms.
Instance Method Summary collapse
-
#asset_root ⇒ String
Where to look for HTML and CSS assets.
-
#login_css ⇒ String
Provides the CSS for the login form.
-
#login_html(env, options = {}) ⇒ String
Provides the HTML for the login form.
Methods included from Rack::ConfigurationHelper
Methods included from Rack::EnvironmentHelper
#authority, #configuration, #interactive?
Instance Method Details
#asset_root ⇒ String
Where to look for HTML and CSS assets.
This is currently hardcoded as ‘(aker gem root)/assets/aker/form`.
20 21 22 23 24 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 20 def asset_root File.(File.join(File.dirname(__FILE__), %w(.. .. ..), %w(assets aker form))) end |
#login_css ⇒ String
Provides the CSS for the login form.
52 53 54 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 52 def login_css File.read(File.join(asset_root, 'login.css')) end |
#login_html(env, options = {}) ⇒ String
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.
42 43 44 45 46 |
# File 'lib/aker/form/login_form_asset_provider.rb', line 42 def login_html(env, = {}) login_base = env['SCRIPT_NAME'] + login_path(env) template = File.read(File.join(asset_root, 'login.html.erb')) ERB.new(template).result(binding) end |