erebor/asciidoctor — pull request #85 by mojavelinux (2013-01-15 22:24:21+00:00)
Title: Optimize rendering and add additional configuration

I stumbled upon two big improvements to performance. The first is that I've eliminated the instance_eval call to get the binding for the node object by adding a get_binding method to AbstractNode. That also allowed me gave the templates access to the template instance so it can access its own methods.

I also made it possible to configure the eRuby implementation. Atm, I've hard-coded ERB and Erubis::FastEruby since that's pretty much the two choices people will want. In the future we could expand the choices.

Finally, I realized that the nested documents inside asciidoc-style tables cells were each creating their own renderer instance. I closed that loop by passing the renderer down to the nested document.

These changes gave us a major boost in performance (now 0.633 sec to render the AsciiDoc User Guide, ~ 24x faster than AsciiDoc).

Here's the full list:

- add get_binding method to node to eliminate instance_eval call before rendering template
- pass renderer to nested document so it isn't reloaded (nested table cells)
- make eRuby implementation configurable (Erubis is measurably faster)
- add erubis as development dependency to run test case
- move strscan import to asciidoctor.rb, remove erb import
- push lazy includes through Asciidoctor.include_library & warn if multi-thread env
- make compacting endlines configurable, off by default
- add tests for preserving endlines w/ and w/o compact option enabled
- run tests w/ compact option disabled
- use instance variable references where possible to speed up rendering
- use map instead of passing a proc to invoke render on blocks because it's faster
- additional TomDoc where missing