Login  Register

How to include dynamically rendered HTML from GitHub source files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

How to include dynamically rendered HTML from GitHub source files

RickEEE
I'm authoring API user documentation using GitHub pages (adocs) and need to include HTML content that is dynamically rendered from XML source docs located within the GitHub repository.  This technique will ensure that the document content is always current -  it auto-generates whenever the Developer updates the XML source code.  Is there a way to use a passthrough block or other technique to make this reality?  

For reference, the following code is how I currently render the XML in an HTML document.  Not sure if this is applicable, but the xsl document parses the XML file and transforms the data into an HTML table and then displays it in a browser.

<!DOCTYPE html>
<html>
<head>

</head>
<body>
<div class="content">
  <script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("fieldParams/ReqParams.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("xsl.xsl") // Transform document.write(xml.transformNode(xsl)) </script></div>
</body>
</html>
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to include dynamically rendered HTML from GitHub source files

mojavelinux
Administrator
@RickEEE,

You bet there is! What you're looking for is, sure enough, is a passthrough block. A passthrough block passes content directly through to the output without doing any processing on it.

Here's an example:

++++
<script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("fieldParams/ReqParams.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("xsl.xsl") // Transform document.write(xml.transformNode(xsl)) </script>
++++


(a passthrough block also accepts a custom list of subs, such as subs=attributes)

However, generally it's not a good idea to mix content and presentation / behavior. A better way of accomplishing a similar result without having to clutter up your content document is the docinfo feature. Just drop the script tag into a file named docinfo-footer.html:

<script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("fieldParams/ReqParams.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("xsl.xsl") // Transform document.write(xml.transformNode(xsl)) </script>

Then activate it when calling Asciidoctor using -a docinfo=shared-footer or add :docinfo: shared-footer to the document header.


It's also possible to introduce docinfo content using the docinfo extension point.

Cheers,

-Dan

On Mon, Feb 18, 2019 at 2:15 PM RickEEE [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I'm authoring API user documentation using GitHub pages (adocs) and need to include HTML content that is dynamically rendered from XML source docs located within the GitHub repository.  This technique will ensure that the document content is always current -  it auto-generates whenever the Developer updates the XML source code.  Is there a way to use a passthrough block or other technique to make this reality?  

For reference, the following code is how I currently render the XML in an HTML document.  Not sure if this is applicable, but the xsl document parses the XML file and transforms the data into an HTML table and then displays it in a browser.

<!DOCTYPE html>
<html>
<head>

</head>
<body>
<div class="content">
  <script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("fieldParams/ReqParams.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("xsl.xsl") // Transform document.write(xml.transformNode(xsl)) </script></div>
</body>
</html>



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/How-to-include-dynamically-rendered-HTML-from-GitHub-source-files-tp6751.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to include dynamically rendered HTML from GitHub source files

RickEEE
Sincere, Thank you, Dan. I did not realize it would be that simple. Keep up the great work.