lib/bulldog/interpolation.rb in bulldog-0.0.3 vs lib/bulldog/interpolation.rb in bulldog-0.0.4
- old
+ new
@@ -1,13 +1,15 @@
module Bulldog
module Interpolation
Error = Class.new(Bulldog::Error)
def self.interpolate(template, record, name, style, overrides={})
- # TODO: would be nice if this wasn't such a special case.
- if overrides[:basename]
- extension = File.extname(overrides[:basename]).sub(/\A./, '')
- overrides[:extension] ||= extension
+ unless overrides[:extension]
+ overrides = overrides.dup
+ overrides[:extension] ||= style[:format]
+ if overrides[:basename]
+ overrides[:extension] ||= File.extname(overrides[:basename]).sub(/\A./, '')
+ end
end
template.gsub(/:(?:(\w+)|\{(\w+?)\})/) do
key = ($1 || $2).to_sym
if (override = overrides[key])
override