Open SevereOverfl0w opened 5 years ago
Hi Dominic,
Asciidoctor core only loads templates from directories in the filesystem. That means all we can do from AsciidoctorJ is to also extract some archive to the filesystem and pass that path to Asciidoctor.
It looks to me as if a Template resolver class would be a new extension point. What do you think, @mojavelinux?
It should be possible to reference templates on the classloader (in other words, that are on the classpath). The syntax is as follows:
-r ./templates.jar -T uri:classloader:templates
This assumes that the templates are in a jar named templates.jar, though this can be any jar on the classpath. The uri:classloader:
prefix tells JRuby to look on the classpath. templates
is a folder at the root of the classpath.
I've added a test in core that verifies this is possible.
It would be really useful to provide templates with a custom resolver. In circumstances where you're only deploying a jar or part of a library.
I've run into this in 2 different contexts:
I solved <1> by leaving mustache tags in the HTML and replacing those later. So that didn't turn out too bad. <2> requires a way to ship things with the library which is already on the classpath.
I think the "fully dynamic" solution of being able to provide a template-resolver class would be very neat. But practically, searching relative to the classpath solves my use-cases along with the mustache solution.