class Asciidoctor::Converter::TemplateConverter
def scan
{TemplateConverter#templates} method.
templates, loads the templates and stores the in a Hash that is accessible via the
Internal: Scans the template directories specified in the constructor for Tilt-supported
def scan path_resolver = PathResolver.new backend = @backend engine = @engine @template_dirs.each do |template_dir| # FIXME need to think about safe mode restrictions here # Ruby 2.3 requires the extra brackets around the path_resolver.system_path method call next unless ::File.directory?(template_dir = (path_resolver.system_path template_dir)) if engine file_pattern = %(*.#{engine}) # example: templates/haml if ::File.directory?(engine_dir = %(#{template_dir}/#{engine})) template_dir = engine_dir end else # NOTE last matching template wins for template name if no engine is given file_pattern = '*' end # example: templates/html5 (engine not set) or templates/haml/html5 (engine set) if ::File.directory?(backend_dir = %(#{template_dir}/#{backend})) template_dir = backend_dir end pattern = %(#{template_dir}/#{file_pattern}) if (scan_cache = @caches[:scans]) template_cache = @caches[:templates] unless (templates = scan_cache[pattern]) templates = scan_cache[pattern] = scan_dir template_dir, pattern, template_cache end templates.each do |name, template| @templates[name] = template_cache[template.file] = template end else @templates.update scan_dir(template_dir, pattern, @caches[:templates]) end end nil end