Class: SuperSettings::Application
- Inherits:
-
Object
- Object
- SuperSettings::Application
- Includes:
- Helper
- Defined in:
- lib/super_settings/application.rb
Overview
Simple class for rendering ERB templates for the HTML application.
Constant Summary
Constants included from Helper
Helper::DEFAULT_ICON_STYLE, Helper::GEAR_SVG, Helper::ICON_BUTTON_STYLE, Helper::ICON_SVG
Instance Method Summary collapse
-
#initialize(layout: nil, add_to_head: nil, api_base_url: nil, color_scheme: nil, dark_mode_selector: nil, read_only: false, locale: nil) ⇒ Application
constructor
A new instance of Application.
-
#render ⇒ String
Render the web UI application HTML.
Methods included from Helper
#add_to_head, #api_base_url, application_header, #application_header, #application_name, #color_scheme, #content_tag, #dark_mode_selector, #html_attributes, #html_escape, #icon_button, #icon_image, #javascript_tag, #layout_style_tag, #read_only?, #render_partial, #style_tag, #t, #tag, #text_direction, #translations_json
Constructor Details
#initialize(layout: nil, add_to_head: nil, api_base_url: nil, color_scheme: nil, dark_mode_selector: nil, read_only: false, locale: nil) ⇒ Application
Returns a new instance of Application.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/super_settings/application.rb', line 20 def initialize(layout: nil, add_to_head: nil, api_base_url: nil, color_scheme: nil, dark_mode_selector: nil, read_only: false, locale: nil) if layout layout = File.(File.join("application", "layout.html.erb"), __dir__) if layout == :default @layout = ERB.new(File.read(layout)) if layout @add_to_head = add_to_head else @layout = nil @add_to_head = nil end @api_base_url = api_base_url @color_scheme = color_scheme&.to_sym @dark_mode_selector = dark_mode_selector @read_only = !!read_only @locale = locale || SuperSettings::MiniI18n::DEFAULT_LOCALE end |
Instance Method Details
#render ⇒ String
Render the web UI application HTML.
40 41 42 43 44 45 46 |
# File 'lib/super_settings/application.rb', line 40 def render template = ERB.new(File.read(File.(File.join("application", "index.html.erb"), __dir__))) html = template.result(binding) html = render_layout { html } if @layout html = html.html_safe if html.respond_to?(:html_safe) html end |