Method: Awestruct::Handlers::BaseTiltHandler#options

Defined in:
lib/awestruct/handlers/base_tilt_handler.rb

#optionsObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/awestruct/handlers/base_tilt_handler.rb', line 87

def options
  opts = {}

  in_ext = input_extension[1..-1].to_sym
  out_ext = output_extension[1..-1].to_sym

  engine_name = ::Tilt[path].name.gsub(/(Awestruct)?(Tilt|:|Template)/i, '').downcase.to_sym

  # example: slim
  engine_opts = site[engine_name]
  unless engine_opts.nil?
    opts.merge! engine_opts
  end

  # example: slim|xml
  engine_opts_for_output = site["#{engine_name}|#{out_ext}"]
  unless engine_opts_for_output.nil?
    opts.merge! engine_opts_for_output
  end

  # config overrides for specific file extension if different from engine name
  unless engine_name == in_ext
    # example: adoc
    in_ext_opts = site[in_ext]
    unless in_ext_opts.nil?
      opts.merge! in_ext_opts
    end

    # example: adoc|xml
    in_ext_opts_for_output = site["#{in_ext}|#{out_ext}"]
    unless in_ext_opts_for_output.nil?
      opts.merge! in_ext_opts_for_output
    end
  end

  return opts
end