diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-01-09 23:35:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-09 23:35:08 -0700 |
| commit | 1641e885e4e101129c50d6ce851a7fcccccee079 (patch) | |
| tree | 01446ca4b9e0e80071e24ca6b3f79ec5b81a3ac9 | |
| parent | 7974f011093dfabbe846bd59ef8f65f7deacec0b (diff) | |
resolves #3006 fix deprecated ERB trim mode (PR #3007)
- use 0 instead of <
- augment test to verify behavior of trim mode
- remove encoding setting from ERB template
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/converter/template.rb | 2 | ||||
| -rw-r--r-- | test/converter_test.rb | 14 | ||||
| -rw-r--r-- | test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb | 2 | ||||
| -rw-r--r-- | test/fixtures/custom-backends/erb/html5/open.html.erb | 8 |
5 files changed, 24 insertions, 3 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2521f48f..48c1dc92 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -41,6 +41,7 @@ Bug Fixes:: * scope constant lookups (#2764) * use byteslice instead of slice to remove BOM from string (#2764) * Reader#push_include should not fail if data is nil + * fix deprecated ERB trim mode that was causing warning (#3006) Build / Infrastructure:: diff --git a/lib/asciidoctor/converter/template.rb b/lib/asciidoctor/converter/template.rb index dc0af224..493feeb1 100644 --- a/lib/asciidoctor/converter/template.rb +++ b/lib/asciidoctor/converter/template.rb @@ -25,7 +25,7 @@ module Asciidoctor # will be issued. class Converter::TemplateConverter < Converter::Base DEFAULT_ENGINE_OPTIONS = { - erb: { trim: '<' }, + erb: { trim: 0 }, # TODO line 466 of haml/compiler.rb sorts the attributes; file an issue to make this configurable # NOTE AsciiDoc syntax expects HTML/XML output to use double quotes around attribute values haml: { format: :xhtml, attr_wrapper: '"', escape_attrs: false, ugly: true }, diff --git a/test/converter_test.rb b/test/converter_test.rb index 53829434..0ceedf15 100644 --- a/test/converter_test.rb +++ b/test/converter_test.rb @@ -225,7 +225,8 @@ Sidebar content end test 'should load ERB templates using ERBTemplate if eruby is not set' do - doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/erb'), template_cache: false + input = %([.wrapper]\n--\nfoobar\n--) + doc = Asciidoctor::Document.new input, template_dir: (fixture_path 'custom-backends/erb'), template_cache: false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph'].each do |node_name| selected = doc.converter.find_converter node_name @@ -236,6 +237,17 @@ Sidebar content assert_kind_of ::ERB, template.instance_variable_get('@engine') assert_equal %(block_#{node_name}.html.erb), File.basename(selected.templates[node_name].file) end + # NOTE verify behavior of trim mode + expected_output = <<-EOS.chomp +<div class="openblock wrapper"> +<div class="content"> +<div class="paragraph"> +<p>foobar</p> +</div> +</div> +</div> + EOS + assert_equal expected_output, doc.convert end test 'should load ERB templates using ErubisTemplate if eruby is set to erubis' do diff --git a/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb b/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb index 7eb80950..eaaef93c 100644 --- a/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +++ b/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb @@ -1,4 +1,4 @@ -<%#encoding:UTF-8%><div<%= @id && %( id="#{@id}") %> class="<%= ['paragraph',role].compact * ' ' %>"><% +<div<%= @id && %( id="#{@id}") %> class="<%= ['paragraph',role].compact * ' ' %>"><% if title? %> <div class="title"><%= title %></div><% end %> diff --git a/test/fixtures/custom-backends/erb/html5/open.html.erb b/test/fixtures/custom-backends/erb/html5/open.html.erb new file mode 100644 index 00000000..ca738ed7 --- /dev/null +++ b/test/fixtures/custom-backends/erb/html5/open.html.erb @@ -0,0 +1,8 @@ +<div<%= @id && %( id="#{@id}") %> class="<%= ['openblock',(@style == 'open' ? nil : @style),role].compact * ' ' %>"><% + if title? %> +<div class="title"><%= title %></div><% + end %> +<div class="content"> +<%= content %> +</div> +</div> |
