class EZML::Options

Attributes

attr_wrapper[R]
autoclose[RW]
cdata[RW]
compiler_class[RW]
encoding[R]
escape_attrs[RW]
escape_html[RW]
filename[RW]
filters[RW]
format[R]
hyphenate_data_attrs[RW]
line[RW]
mime_type[RW]
parser_class[RW]
preserve[RW]
remove_whitespace[R]
suppress_eval[RW]
trace[RW]

Public Class Methods

buffer_defaults() click to toggle source
# File lib/ezml/options.rb, line 22
def self.buffer_defaults
  @buffer_defaults ||= buffer_option_keys.inject({}) do |hash, key|
    hash.merge(key => defaults[key])
  end
end
buffer_option_keys() click to toggle source
# File lib/ezml/options.rb, line 18
def self.buffer_option_keys
  @buffer_option_keys
end
defaults() click to toggle source
# File lib/ezml/options.rb, line 10
def self.defaults
  @defaults ||= EZML::TemplateEngine.options.to_hash.merge(encoding: 'UTF-8')
end
new(values = {}) { || ... } click to toggle source
# File lib/ezml/options.rb, line 55
def initialize(values = {}, &block)
  defaults.each {|k, v| instance_variable_set :"@#{k}", v}
  values.each {|k, v| send("#{k}=", v) if defaults.has_key?(k) && !v.nil?}
  yield if block_given?
end
valid_formats() click to toggle source
# File lib/ezml/options.rb, line 14
def self.valid_formats
  @valid_formats
end
wrap(options) click to toggle source
# File lib/ezml/options.rb, line 28
def self.wrap(options)
  if options.is_a?(Options)
    options
  else
    Options.new(options)
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/ezml/options.rb, line 61
def [](key)
  send key
end
[]=(key, value) click to toggle source
# File lib/ezml/options.rb, line 65
def []=(key, value)
  send "#{key}=", value
end
attr_wrapper=(value) click to toggle source
# File lib/ezml/options.rb, line 93
def attr_wrapper=(value)
  @attr_wrapper = value || self.class.defaults[:attr_wrapper]
end
encoding=(value) click to toggle source
# File lib/ezml/options.rb, line 118
def encoding=(value)
  return unless value
  @encoding = value.is_a?(Encoding) ? value.name : value.to_s
  @encoding = "UTF-8" if @encoding.upcase == "US-ASCII"
end
for_buffer() click to toggle source
# File lib/ezml/options.rb, line 124
def for_buffer
  self.class.buffer_option_keys.inject({}) do |hash, key|
    value = public_send(key)
    if self.class.buffer_defaults[key] != value
      hash[key] = value
    end
    hash
  end
end
format=(value) click to toggle source
# File lib/ezml/options.rb, line 102
def format=(value)
  unless self.class.valid_formats.include?(value)
    raise EZML::Error, "Invalid output format #{value.inspect}"
  end
  @format = value
end
html4?() click to toggle source
# File lib/ezml/options.rb, line 85
def html4?
  format == :html4
end
html5?() click to toggle source
# File lib/ezml/options.rb, line 89
def html5?
  format == :html5
end
html?() click to toggle source
# File lib/ezml/options.rb, line 81
def html?
  html4? or html5?
end
remove_whitespace=(value) click to toggle source
# File lib/ezml/options.rb, line 114
def remove_whitespace=(value)
  @remove_whitespace = value
end
xhtml?() click to toggle source
# File lib/ezml/options.rb, line 77
def xhtml?
  not html?
end

Private Instance Methods

defaults() click to toggle source
# File lib/ezml/options.rb, line 136
def defaults
  self.class.defaults
end