Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi,
last night I was talking with Aslak and we found an improvement on backends. Nowdays backends are set as directory using templateDir . Then in that directory you should create a directory like: block_admonition.html.slim and then you add the content in slim format in this case. We think that it would be useful that we can add backends definition programmatically as stream. Something like: {:block_amonition.html.slim => stream} The stream could be in case of Java any instance of InputStream so for example you could store your backends to a site and refer it directly without having to download locally. This can be done in AsciidoctorJ by intercepting streams and populate into temp directory, but f it could be implemented in Ruby all Asciidoctor users could use it. WDYT? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Stream's are a bit difficult to read multiple times of course..
But {:block_amonition.html.slim => content_string} would work as a charm :) |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Good point then as string, this would require some changes on public API, and for example a way to give a template a name so it can be loaded on demand, or for example decide that if you register a template programmatically then it is loaded by default for all invocations. But I think it would be more flexible (and I am thinking of a Java EE application) to be able to enable or disable or create them dynamically.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Aslak Knutsen
In fact, it's possible to pass a custom template as a string in 1.5.0. One way to do it is to load the document, register a string-based template for a given context, then convert. [source,ruby] ---- require 'asciidoctor' require 'asciidoctor/extensions' require 'tilt' paragraph_template = Tilt.new 'paragraph.html.slim' do |t| <<-EOS p=content EOS end doc = Asciidoctor.load 'paragraph', template_dirs: [] doc.converter.converters.first.register 'paragraph', paragraph_template puts doc.convert ---- Another way is to use the converter factory directly to create a composite converter with the string-based template preregistered, then pass the converter as an option to the Asciidoctor API: [source,ruby] ---- converter = Asciidoctor::Converter::Factory.default.create 'html5', template_dirs: [] converter.converters.first.register 'paragraph', paragraph_template puts Asciidoctor.convert 'paragraph', converter: converter ---- I agree the register method should be easier to call. That's going to need to be filed as a request for enhancement. We might be able to use some Ruby metaprogramming to delegate methods intelligently from the composite to the underlying converter. You may find this class interesting: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/factory.rb Btw, I still have plans to integrate the convert API into the extension APIs so that they can be registered globally like extensions. Cheers, -Dan On Sun, Mar 9, 2014 at 11:54 AM, Aslak Knutsen [via Asciidoctor :: Discussion] <[hidden email]> wrote: Stream's are a bit difficult to read multiple times of course.. Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |