-
Notifications
You must be signed in to change notification settings - Fork 1
The converter factory should returns a CompositeConverter #4
Comments
That should be enough. That's how the composite template decides which converter should handle the node. def find_converter transform
@converters.each do |candidate|
return candidate if candidate.handles? transform
end
raise %(Could not find a converter to handle transform: #{transform})
end Keep in mind, though, the |
That's what I did but "find_converter" does not fallback on html5 converter. Le 2 oct. 2016 1:16 AM, "Dan Allen" notifications@github.com a écrit :
|
Aha. That's because the base converter is selected according to the backend, which you've changed to revealjs. That's why I explicitly create the Html5Converter in the Bespoke converter. See https://github.com/asciidoctor/asciidoctor-bespoke/blob/master/lib/asciidoctor-bespoke/converter.rb#L30 |
In other words, we have a bit of a chicken-egg problem. The backend determines the base converter, but then you can't use the backend to select the composite converter. I haven't really figured that out yet. One solution would be to use the basebackend instead of the backend to select the base converter. The only problem is that we don't pass that information. |
That's why right now, when you are using the template converter (and not your own composite converter), you should always set the backend to what you want the base converter to be. But we need a better solution. |
@mojavelinux Ok I think I now understand why this was not working. I was using the attribute The only drawback is that the following code will not work anymore: https://github.com/asciidoctor/asciidoctor-template.js/blob/master/lib/asciidoctor/core_ext/factory.rb#L38-L42 if backend == 'revealjs' && (JAVASCRIPT_PLATFORM == 'node' || JAVASCRIPT_PLATFORM == 'node-electron')
if ::File.exist?(revealjs_templates_path = 'node_modules/asciidoctor-reveal.js/templates')
opts[:template_dirs] = revealjs_templates_path unless opts.key? :template_dirs
end
end But this was an ugly hack anyway 😉 |
Agreed. I do think that the factory should have access to both the backend and the basebackend. Then we could actually do this sort of layering. I've added a node to look at this in core. Until then, the custom composite converter setup the way you describe is the way to go. |
Resolves #4, Reintroduce the CompositeConverter
To have a consistent experience between Asciidoctor Ruby and Asciidoctor.js, the converter factory should returns a CompositeConverter:
@mojavelinux During my tests I've tried to remove the
embedded
template from the Reveal.js backend expecting a fallback on the HTML5 backend but instead I got:Do I have to configure something special in template.rb ?
I did implement
handles?
method intemplate.rb
but apparently that's not enough...The text was updated successfully, but these errors were encountered: