lib/awestruct/handlers/base_tilt_handler.rb in awestruct-0.5.4.rc3 vs lib/awestruct/handlers/base_tilt_handler.rb in awestruct-0.5.4
- old
+ new
@@ -10,16 +10,21 @@
# Returns the Tilt template class if a portion of the path is registered
# to a Tilt template and the Tilt template can be loaded. Returns false
# if no portions of the path are registered to a Tilt template or the
# Tilt template cannot be loaded.
def match(path)
- begin
- Tilt[File.basename(path)]
- rescue LoadError => e
- $LOG.warn(%(Copying #{path} to generated site without processing; missing required gem -- #{e.message.split(/ *-- */).last} (or equivalent)))
- false
+ matcher = ::Tilt[File.basename(path)]
+ if matcher.nil?
+ $LOG.warn(%(Copying #{path} to generated site without processing; could not load engine for type))
+ return false
end
+
+ # We have our own extra integration with Asciidoctor
+ if matcher.name.include? 'Asciidoctor'
+ return false
+ end
+ matcher
end
end
class BaseTiltHandler < BaseHandler
@@ -53,11 +58,11 @@
end
def output_extension
return File.extname(File.basename(source_file_name, File.extname(source_file_name))) if double_extension?
- template = Tilt[path]
+ template = ::Tilt[path]
if !template.nil?
mime = template.default_mime_type
if !mime.nil?
return '.js' if mime.eql? 'application/javascript'
return '.html' if mime.eql? 'text/html'
@@ -84,11 +89,11 @@
opts = {}
in_ext = input_extension[1..-1].to_sym
out_ext = output_extension[1..-1].to_sym
- engine_name = Tilt[path].name.gsub(/(Tilt|:|Template)/i, '').downcase.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
@@ -122,10 +127,10 @@
$LOG.debug "invoking tilt for #{delegate.path} with_layouts = #{with_layouts}" if $LOG.debug?
begin
c = delegate.rendered_content(context, with_layouts)
return "" if c.nil? or c.empty?
- template = Tilt::new(delegate.path.to_s, delegate.content_line_offset + 1, options) { |engine|
+ template = ::Tilt::new(delegate.path.to_s, delegate.content_line_offset + 1, options) { |engine|
c
}
return template.render(context)
rescue LoadError => e
ExceptionHelper.log_message "Could not load template library required for rendering #{File.join site.dir, relative_source_path}."