summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2018-03-21 00:55:41 -0600
committerGitHub <noreply@github.com>2018-03-21 00:55:41 -0600
commitbd1c5288dcb6ed2bea61ddbdd3142e470b77fec6 (patch)
treed3714be3e2721f8da480d0eb65fdc0b1dff7e425
parent47c69196770a5e50b398e49810f18dc8e32bb449 (diff)
coerce value of template_dirs option to an Array (PR #2621)
-rw-r--r--lib/asciidoctor/document.rb7
-rw-r--r--test/converter_test.rb9
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index 5d4f945b..08eb31b8 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -1075,12 +1075,13 @@ class Document < AbstractBlock
def create_converter
converter_opts = {}
converter_opts[:htmlsyntax] = @attributes['htmlsyntax']
- template_dirs = if (template_dir = @options[:template_dir])
- converter_opts[:template_dirs] = [template_dir]
+ if (template_dir = @options[:template_dir])
+ template_dirs = [template_dir]
elsif (template_dirs = @options[:template_dirs])
- converter_opts[:template_dirs] = template_dirs
+ template_dirs = Array template_dirs
end
if template_dirs
+ converter_opts[:template_dirs] = template_dirs
converter_opts[:template_cache] = @options.fetch :template_cache, true
converter_opts[:template_engine] = @options[:template_engine]
converter_opts[:template_engine_options] = @options[:template_engine_options]
diff --git a/test/converter_test.rb b/test/converter_test.rb
index def8bb9a..bc7ba607 100644
--- a/test/converter_test.rb
+++ b/test/converter_test.rb
@@ -39,6 +39,15 @@ context 'Converter' do
assert_equal template_dirs.reverse.map {|dir| File.expand_path dir }, selected.templates['paragraph'].options[:include_dirs]
end
+ test 'should coerce template_dirs option to an Array' do
+ template_dirs = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim')
+ doc = Asciidoctor::Document.new [], :template_dirs => template_dirs, :template_cache => false
+ assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
+ selected = doc.converter.find_converter('paragraph')
+ assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
+ assert_kind_of Array, (selected.instance_variable_get :@template_dirs)
+ end
+
test 'should set Slim format to html for html5 backend' do
doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter