diff options
| author | Dan Allen <dallen@redhat.com> | 2013-06-19 00:59:05 -0600 |
|---|---|---|
| committer | Dan Allen <dallen@redhat.com> | 2013-06-20 00:35:53 -0600 |
| commit | 8911f46bbd90fbac69633763e1c0fd093d650965 (patch) | |
| tree | c0df570ca545c820d4a1a89eb4a1e114c7a1be14 | |
| parent | 9d2eec9e445b00c6c5619b95e4d9ab3e19fddba0 (diff) | |
resolves #406 add option to cli to specify template engine
| -rw-r--r-- | lib/asciidoctor/cli/options.rb | 4 | ||||
| -rw-r--r-- | man/asciidoctor.1 | 9 | ||||
| -rw-r--r-- | man/asciidoctor.ad | 5 | ||||
| -rw-r--r-- | test/invoker_test.rb | 8 | ||||
| -rw-r--r-- | test/options_test.rb | 5 |
5 files changed, 29 insertions, 2 deletions
diff --git a/lib/asciidoctor/cli/options.rb b/lib/asciidoctor/cli/options.rb index 2f0a2e7c..cf61fae7 100644 --- a/lib/asciidoctor/cli/options.rb +++ b/lib/asciidoctor/cli/options.rb @@ -13,6 +13,7 @@ module Asciidoctor self[:safe] = options[:safe] || SafeMode::UNSAFE self[:header_footer] = options[:header_footer] || true self[:template_dir] = options[:template_dir] || nil + self[:template_engine] = options[:template_engine] || nil if options[:doctype] self[:attributes]['doctype'] = options[:doctype] end @@ -90,6 +91,9 @@ Example: asciidoctor -b html5 source.asciidoc opts.on('-T', '--template-dir DIR', 'directory containing custom render templates the override the built-in set') do |template_dir| self[:template_dir] = template_dir end + opts.on('-E', '--template-engine NAME', 'template engine to use for the custom render templates (loads gem on demand)') do |template_engine| + self[:template_engine] = template_engine + end opts.on('-B', '--base-dir DIR', 'base directory containing the document and resources (default: directory of source file)') do |base_dir| self[:base_dir] = base_dir end diff --git a/man/asciidoctor.1 b/man/asciidoctor.1 index f1b76b1b..2e0a0b64 100644 --- a/man/asciidoctor.1 +++ b/man/asciidoctor.1 @@ -2,12 +2,12 @@ .\" Title: asciidoctor .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 05/30/2013 +.\" Date: 06/19/2013 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "ASCIIDOCTOR" "1" "05/30/2013" "\ \&" "\ \&" +.TH "ASCIIDOCTOR" "1" "06/19/2013" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -136,6 +136,11 @@ Compact the output by removing blank lines\&. Not enabled by default\&. Destination output directory\&. Defaults to the directory containing the source file, or the working directory if the source is read from a stream\&. If specified, the directory is resolved relative to the working directory\&. .RE .PP +\fB\-E, \-\-template\-engine\fR=\fINAME\fR +.RS 4 +Template engine to use for the custom render templates\&. The gem with the same name as the engine will be loaded automatically\&. This name is also used to build the full path to the custom templates\&. +.RE +.PP \fB\-e, \-\-eruby\fR .RS 4 Specifies the eRuby implementation to use for rendering the built\-in templates\&. Supported values are diff --git a/man/asciidoctor.ad b/man/asciidoctor.ad index 7cdb4281..e44e8beb 100644 --- a/man/asciidoctor.ad +++ b/man/asciidoctor.ad @@ -87,6 +87,11 @@ Rendering Control source file, or the working directory if the source is read from a stream. If specified, the directory is resolved relative to the working directory. +*-E, --template-engine*='NAME':: + Template engine to use for the custom render templates. The gem with the + same name as the engine will be loaded automatically. This name is also + used to build the full path to the custom templates. + *-e, --eruby*:: Specifies the eRuby implementation to use for rendering the built-in templates. Supported values are 'erb' and 'erubis'. Defaults to 'erb'. diff --git a/test/invoker_test.rb b/test/invoker_test.rb index eb0e30e2..f37a827a 100644 --- a/test/invoker_test.rb +++ b/test/invoker_test.rb @@ -240,6 +240,14 @@ context 'Invoker' do assert_xpath '/html/body[@class="book"]', output, 1 end + # enable after merging tilt tests + #test 'should locate custom templates based on template dir, template engine and backend' do + # custom_backend_root = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) + # invoker = invoke_cli_to_buffer %W(-E haml -T #{custom_backend_root} -o -) + # doc = invoker.document + # assert doc.renderer.views['block_paragraph'].is_a? Tilt::HamlTemplate + #end + test 'should set attribute with value' do invoker = invoke_cli_to_buffer %w(--trace -a idprefix=id -s -o -) doc = invoker.document diff --git a/test/options_test.rb b/test/options_test.rb index 7c51cd33..82e24fe7 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -92,4 +92,9 @@ context 'Options' do assert_equal 'inline', options[:attributes]['doctype'] end + test 'template engine assignment' do + options = Asciidoctor::Cli::Options.parse!(%w(-E haml test/fixtures/sample.asciidoc)) + assert_equal 'haml', options[:template_engine] + end + end |
