Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write documentation that explains how to customize the converter output using templates #3948

Closed
mojavelinux opened this issue Jul 1, 2013 · 18 comments
Assignees
Labels
documentation v2.0.17 Issues resolved in the 2.0.17 release v2.1.0 Issues resolved in the 2.1.0 release.
Milestone

Comments

@mojavelinux
Copy link
Member

Write documentation that explains how to create a custom backend. Information to be covered includes:

  • What template languages can be used (answer: anything supported by Tilt)
  • The names of each template and how the file is named
  • What objects are available to the template
  • Brief documenation about the structure of an Asciidoctor document object model
  • Commonly used instance variables and methods in the template

Some starting material can be found here:

asciidoctor/asciidoctor-backends#12 (comment)

@ghost ghost assigned mojavelinux Jul 1, 2013
@obilodeau
Copy link
Member

Until the back-end documentation gets written I think this advice by @mojavelinux should be highlighted here:

p.s. To see which attributes are available, you can print them using:

- puts @document.attributes.inspect
- puts @attributes.inspect

http://discuss.asciidoctor.org/How-can-we-pass-parameters-to-HAML-HTML5-backend-template-td1036.html#a1076

Works with haml and slim templates.

@obilodeau
Copy link
Member

- puts instance_variables
- puts local_variables
- puts @document.methods
...

is also verify useful to understand what is available to the back-end writer

edit: added other interesting things to look at to understand what you have access to

@mojavelinux
Copy link
Member Author

You might find pp to produce better output (and in some cases not).

- require 'pp'
- pp @document.attributes

@mojavelinux
Copy link
Member Author

Questions to answer:

  • What can I accomplish using templates? What is the purpose of templates?
  • What is a template? How does it fit into the Asciidoctor processor?
  • What libraries do I need to make templates? (prerequisites)
  • How do I make a template? What does a template look like?
  • What information is available to a template (APIs, context)?
  • How many templates do I need to make?
  • Where do I put the templates?
  • How do I use templates? What are the parameters I need to specify?
  • How do I use templates with a build tool like Maven or Gradle?

@mojavelinux
Copy link
Member Author

@jaredmorgs
Copy link
Member

When this ticket is resolved, be sure to close off asciidoctor/asciidoctor.org#452 so user-guide.adoc contributors know they no longer need to discuss the section.

@kastork
Copy link

kastork commented Dec 30, 2015

just tossing a +1 on this

@mojavelinux mojavelinux changed the title Write documentation that explains how to create a custom backend Write documentation that explains how to customize the output using templates Jan 5, 2016
@mojavelinux mojavelinux changed the title Write documentation that explains how to customize the output using templates Write documentation that explains how to customize the converter output using templates Jan 5, 2016
@mojavelinux
Copy link
Member Author

Here's some excellent material about why and how to use Pry to debug templates, contributed by @obilodeau. Definitely a key addition to this guide.

http://discuss.asciidoctor.org/Interactively-debugging-a-template-with-a-REPL-td4498.html#a4502

@jcayouette
Copy link

jcayouette commented Aug 21, 2018

+100 on this topic, I think it extremely valuable. I would love to contribute here, however, my other projects do not allow me the time currently. :( If my status changes perhaps Ill spend a hackweek on it 👍

@settermjd
Copy link

This looks like something I could sink my teeth into, allowing for available time.

@tomschr
Copy link

tomschr commented Aug 17, 2021

It seems quite a while that this issue is open. Would be really helpful to see templates being described in the documentation. At the moment, it's hard to find all the necessary bits and pieces and put them together. It's annoying and time consuming.

Please also consider, not everybody is familiar with Ruby. 😉 Some expressions and notations should be explained. Thanks!

@mojavelinux
Copy link
Member Author

I'm quite aware this documentation is sorely needed. If there were more hours in the day, I could get to it. But I'm already giving everything I've got (and then way more). (And the same is probably true for majority of the other maintainers in Asciidoctor).

While the documentation will certainly cover some basic concepts of Ruby, the templates are a programming construct and it's not the appropriate place to teach those concepts. We will be sensitive with the use of terms, but will likely link out to tutorials that you can read.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Oct 5, 2021
@mojavelinux
Copy link
Member Author

At long last, a draft is ready! See #4180.

@mojavelinux
Copy link
Member Author

I still have a bit of work to do to before merging to integrate the information from the linked resources.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Oct 13, 2021
@mojavelinux
Copy link
Member Author

The documentation is now ready for review. I'll leave the PR up for a day or two to see if I get any feedback.

@mojavelinux mojavelinux added this to the v2.1.x milestone Oct 13, 2021
@mojavelinux
Copy link
Member Author

Backport this change to v2.0.x.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Oct 14, 2021
Code review and revisions provided by Tom Schraitle
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Oct 14, 2021
Code review and revisions provided by Tom Schraitle
@mojavelinux mojavelinux added v2.0.17 Issues resolved in the 2.0.17 release v2.1.0 Issues resolved in the 2.1.0 release. labels Oct 15, 2021
@mojavelinux
Copy link
Member Author

mojavelinux commented Oct 15, 2021

I'm pleased to announce that the documentation for converter templates is now available!

https://docs.asciidoctor.org/asciidoctor/latest/convert/templates/

Thanks to @tomschr for reviewing the content and proposing revisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation v2.0.17 Issues resolved in the 2.0.17 release v2.1.0 Issues resolved in the 2.1.0 release.
Projects
None yet
Development

No branches or pull requests

8 participants