Sha256: 6d76915bff1be356dd6c06c53409f1406ef6ead5afc0a5a27de3fccac6531d87

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

class Hyde
class Config < OpenStruct
  DEFAULTS = {
    :site_path => '.',
    :layouts_path => nil,
    :extensions_path => nil,
    :partials_path => nil,
    :output_path => nil
  }

  def self.load(config_file)
    new(YAML::load_file(config_file)) rescue new
  end

  def initialize(options={})
    # Try to emulate proper .merge behavior in Ruby 1.8
    options.each { |k, v| options[k] ||= DEFAULTS[k]  if DEFAULTS.keys.include?(k) }
    super options
  end

  # Returns tilt options for a given file.
  # @example tilt_options('index.haml')  # { :escape_html => ... }
  def tilt_options_for(file, options)
    ext = file.split('.').last.downcase
    opts = tilt_options(ext) || Hash.new
    opts = opts.merge(tilt_options(ext, :tilt_build_options) || Hash.new)  if options[:build]
    opts
  end

  # Returns tilt options for a given engine.
  # @example tilt_options('haml')  # { :escape_html => ... }
  def tilt_options(what, key=:tilt_options)
    @table[key] ||= begin
      h = Hash.new { |h, k| h[k] = Hash.new }
      h['haml'] = { :escape_html => true }
      h['scss'] = { :load_path => ['css'] }
      h['sass'] = { :load_path => ['css'] }
      h
    end

    @table[key][what.to_s]
  end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydeweb-0.1.13 lib/hyde/config.rb
hydeweb-0.1.12 lib/hyde/config.rb
hydeweb-0.1.11 lib/hyde/config.rb
hydeweb-0.1.10 lib/hyde/config.rb
hydeweb-0.1.9 lib/hyde/config.rb