Module: MasterView::FeaturesInfo

Defined in:
lib/masterview/masterview_info.rb

Overview

:nodoc:

Constant Summary collapse

CONTAINER_HTML =

Jeff’s original rendering

"<table%s>\n<thead>\n  <tr><th>Feature</th><th>Loaded</th></tr>\n</thead>\n<tbody>\n%s\n</tbody>\n</table>"
DEFAULT_RENDERING_OPTIONS =
ConfigInfoHelpers::DEFAULT_RENDERING_OPTIONS.clone
FEATURE_SPECS =
[
  # [ <option_name>, <label>, <type> ]
  [ :tidy_template_read, 'Filter templates through tidy on read', 'boolean' ],
  [ :rails_parse_at_startup, 'Parse templates at startup', 'boolean' ],
  [ :rails_reparse_checking, 'Reparse modified templates', 'boolean' ],
  [ :rails_erb_mv_direct, 'Read ERB directly from MasterView', 'boolean' ],
]

Class Method Summary collapse

Class Method Details

.getHtmlTemplate(element_option_name, params) ⇒ Object

already is: DEFAULT_RENDERING_OPTIONS = ”



268
269
270
# File 'lib/masterview/masterview_info.rb', line 268

def self.getHtmlTemplate(element_option_name, params)
  ConfigInfoHelpers.getHtmlTemplate( element_option_name, params, DEFAULT_RENDERING_OPTIONS )
end

.to_html(params = {}) ⇒ Object

Answer an html rendering of the Loaded Features Optionally provide HTML fragment templates and class/style attributes to customize rendering



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/masterview/masterview_info.rb', line 282

def self.to_html( params={} )

  features = MasterView::LoadedFeatures

  # unpack the supported keyword args
  title_html_template = getHtmlTemplate( :title, params )  #parms: config settings title
  preamble_html_template = getHtmlTemplate( :preamble, params ) #parms: MasterView version
  config_settings_html_template = getHtmlTemplate( :container, params ) #parms: section/option entries
  section_entry_html_template = getHtmlTemplate( :section_entry, params ) #parms: :section_attrs, section_name
  option_entry_html_template = getHtmlTemplate( :option_entry, params ) #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
  option_subentry_entry_html_template = params.fetch( :option_subentry_entry, '<tr><td colspan="2" style="font-style: italic; padding-left: 20px;">%s</td></tr>' )
  postscript_html = ConfigInfoHelpers.getHtmlTemplate( :postscript, params )

  # prepare our templates for convenient use during the generation loop below
  config_settings_html_start, config_settings_html_end = config_settings_html_template.split('%s')

  # and off we go at last
  config = MasterView::ConfigSettings
  html = []
  unless title_html_template == :none  # allow client to suppress
    html << title_html_template % [ 'MasterView Configuration' ]
  end
  unless preamble_html_template == :none  # allow client to suppress
    html << preamble_html_template % [ MasterView::VERSION::STRING ]
  end
  html << config_settings_html_start
  # Loaded features
  html << section_entry_html_template % [ 'Feature', 'Loaded' ]
  FEATURE_SPECS.each {| option_name, label, value_type |
    option_value = features[option_name]
    option_value = option_value ? 'true' : 'false' if value_type == 'boolean'
    html << option_entry_html_template % [ label, option_value ]
  }
  html << config_settings_html_end
  html << postscript_html if postscript_html
  html.join("\n")

end