diff options
| author | Dan Allen <dallen@redhat.com> | 2013-06-24 10:51:58 -0600 |
|---|---|---|
| committer | Dan Allen <dallen@redhat.com> | 2013-06-24 21:02:22 -0600 |
| commit | 45567eecccf17132cebf70c606b778751c2e50d1 (patch) | |
| tree | 3709dcb793e7fbbebd0bb86a46948804a98f66ae | |
| parent | f2d12e2071f90b111dfd3e714d40f4562cda62eb (diff) | |
optimize admonition template
| -rw-r--r-- | lib/asciidoctor/backends/html5.rb | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/asciidoctor/backends/html5.rb b/lib/asciidoctor/backends/html5.rb index 8eb42d82..6e6d26f0 100644 --- a/lib/asciidoctor/backends/html5.rb +++ b/lib/asciidoctor/backends/html5.rb @@ -470,28 +470,37 @@ class BlockLiteralTemplate < BaseTemplate end class BlockAdmonitionTemplate < BaseTemplate - def template - @template ||= @eruby.new <<-EOS -<%#encoding:UTF-8%><div#{id} class="admonitionblock <%= attr :name %>#{role_class}"> + def result(node) + id = node.id + name = node.attr 'name' + role = node.role + title = node.title? ? node.title : nil + if node.attr? 'icons' + if node.attr? 'icons', 'font' + caption = %(<i class="icon-#{name}" title="#{node.caption}"></i>) + else + caption = %(<img src="#{node.icon_uri(name)}" alt="#{node.caption}">) + end + else + caption = %(<div class="title">#{node.caption}</div>) + end + %(<div#{id && " id=\"#{id}\""} class="admonitionblock #{name}#{role && " #{role}"}"> <table> <tr> -<td class="icon"><% -if attr? 'icons', 'font' %> -<i class="icon-<%= attr :name %>" title="<%= @caption %>"></i><% -elsif attr? 'icons' %> -<img src="<%= icon_uri(attr :name) %>" alt="<%= @caption %>"><% -else %> -<div class="title"><%= @caption %></div><% -end %> +<td class="icon"> +#{caption} </td> -<td class="content"> -#{title_div} -<%= content %> +<td class="content">#{title ? " +<div class=\"title\">#{title}</div>" : nil} +#{node.content} </td> </tr> </table> -</div> - EOS +</div>\n) + end + + def template + :invoke_result end end |
