Asciidoctor Backend question - add a cover.html.slim

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Asciidoctor Backend question - add a cover.html.slim

ch007m
Hi,

Is there a way to tell to asciidoctor that a specific template file of the backend (xxx.html.slim) must be used for the rendering (asciidoc to HTML) ?

My idea is the following. I would like to add a HTML slim template under backends/slim/html5/cover.html.slim but as the cover does not correspond to a block/macro managed by asciidoctor (document, section, image, paragraph, video, ...) I don't know until now If I can pass an attribute to tell to asciidoctor which template page it should use for the rendering. The alternative is of course to create a new backend but until now it will just contain a document.html.slim (= cover template)

Regards,
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor Backend question - add a cover.html.slim

ch007m
The workaround that I'm using now is to use directly slim ... but in this case I bypass asciidoctor from hyla

            Hyla.logger.info "Rendering : Generate Cover HTML page & picture - format png"

            out_dir = options[:destination] if self.check_mandatory_option?('-d / --destination', options[:destination])
            file_name = options[:cover_file]
            image_name = options[:cover_image]

            # Configure Slim engine
            slim_file = Configuration::cover_template
            slim_tmpl = File.read(slim_file)
            template = Slim::Template.new(:pretty => true) { slim_tmpl }

            # Do the Rendering HTML
            res = template.render(Object.new, :course_name => options[:course_name], :module_name => options[:module_name], :image_path => options[:image_path])
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor Backend question - add a cover.html.slim

mojavelinux
Administrator
The "correct" thing to do here is to create a new backend since you are, in affect, creating a new type of output.

This becomes a lot simpler in Asciidoctor 1.5.0 since we now have a TemplateConverter that can be used to hide the plumbing of setting up a template-based backend for a case like this one. I encourage you to have a look at the new API and see if it fits your needs.

https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/factory.rb#L201
https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/template.rb

We may need to revise it as the requirements emerge.

Also in 1.5.0 it will be possible to call up a converter transform (read as template) on demand using:

converters.convert node, 'cover'

Again, we may need to revise the API as the requirements emerge. It's a draft and starting point.

-Dan


On Wed, Mar 5, 2014 at 1:24 AM, ch007m [via Asciidoctor :: Discussion] <[hidden email]> wrote:
The workaround that I'm using now is to use directly slim ... but in this case I bypass asciidoctor from hyla

            Hyla.logger.info "Rendering : Generate Cover HTML page & picture - format png"

            out_dir = options[:destination] if self.check_mandatory_option?('-d / --destination', options[:destination])
            file_name = options[:cover_file]
            image_name = options[:cover_image]

            # Configure Slim engine
            slim_file = Configuration::cover_template
            slim_tmpl = File.read(slim_file)
            template = Slim::Template.new(:pretty => true) { slim_tmpl }

            # Do the Rendering HTML
            res = template.render(Object.new, :course_name => options[:course_name], :module_name => options[:module_name], :image_path => options[:image_path])
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-Backend-question-add-a-cover-html-slim-tp1576p1578.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--