Class: Middleman::MetaPages::ConfigSetting

Inherits:
Object
  • Object
show all
Includes:
Padrino::Helpers::OutputHelpers, Padrino::Helpers::TagHelpers
Defined in:
lib/middleman-core/meta_pages/config_setting.rb

Overview

View class for a config entry

Constant Summary

Constants included from Padrino::Helpers::TagHelpers

Padrino::Helpers::TagHelpers::BOOLEAN_ATTRIBUTES, Padrino::Helpers::TagHelpers::DATA_ATTRIBUTES, Padrino::Helpers::TagHelpers::ESCAPE_REGEXP, Padrino::Helpers::TagHelpers::ESCAPE_VALUES, Padrino::Helpers::TagHelpers::NEWLINE

Instance Method Summary collapse

Methods included from Padrino::Helpers::TagHelpers

#content_tag, #input_tag, #safe_content_tag, #tag

Methods included from Padrino::Helpers::OutputHelpers

#block_is_template?, #capture_html, #concat_content, #concat_safe_content, #content_for, #content_for?, handlers, included, register, #yield_content

Constructor Details

#initialize(setting) ⇒ ConfigSetting

Returns a new instance of ConfigSetting.



8
9
10
# File 'lib/middleman-core/meta_pages/config_setting.rb', line 8

def initialize(setting)
  @setting = setting
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/middleman-core/meta_pages/config_setting.rb', line 12

def render
  content = ""
  key_classes = ['key']
  key_classes << 'modified' if @setting.value_set?
  content << (:span, @setting.key.inspect, :class => key_classes.join(' '))
  content << " = "
  content << (:span, @setting.value.inspect, :class => 'value')
  if @setting.default
    content << (:span, :class => 'default') do
      if @setting.value_set?
        "Default: #{@setting.default.inspect}"
      else
        "(Default)"
      end
    end
  end

  if @setting.description
    content << (:p, :class => 'description') do
      CGI::escapeHTML(@setting.description)
    end
  end

  content
end