lib/yard/templates/engine.rb in yard-0.8.1 vs lib/yard/templates/engine.rb in yard-0.8.2
- old
+ new
@@ -80,11 +80,11 @@
# @return [String] the rendered template
def render(options = {})
options = set_default_options(options)
mod = template(options.template, options.type, options.format)
- if options.serialize != false
+ if options.serializer && options.serialize != false
with_serializer(options.object, options.serializer) { mod.run(options) }
else
mod.run(options)
end
end
@@ -110,14 +110,21 @@
# @param [Serializers::Base] serializer the serializer object
# @yield a block whose result will be serialize
# @yieldreturn [String] the contents to serialize
# @see Serializers::Base
def with_serializer(object, serializer, &block)
- serializer.before_serialize if serializer
- output = yield
- if serializer
- serializer.serialize(object, output)
- serializer.after_serialize(output)
+ output = nil
+ filename = serializer.serialized_path(object)
+ if serializer.respond_to?(:basepath)
+ filename = File.join(serializer.basepath, filename)
+ end
+ log.capture("Generating #{filename}", nil) do
+ serializer.before_serialize if serializer
+ output = yield
+ if serializer
+ serializer.serialize(object, output)
+ serializer.after_serialize(output)
+ end
end
output
end
private