User-Defined Attribute in Include tags

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

User-Defined Attribute in Include tags

zombi
I have a need for a document to somewhat dynamically produce content based on the type of output document desired. For example, we have a document that will be used internally by our team as well as externally outside our team and while there is a high percentile of overlapping of information, not everything made available in the internal version of the document should be included in the external version of the document.

I have used Tags to help address this by having child .adoc files for all of the main content with includes statements in a parent.adoc that will produce the output based on those tags. Right now I have everything working, but I have to maintain two "parent" files that incorporate the includes of the child.adoc files; one for 'internal' and one for 'external'.

I'm wondering if there is a way to have an attribute defined in the parent document be used to specify the tag name in the include statement? Something like below so that I could update the output_type attribute and won't have to maintain two highly identical parent.adoc files. The only difference between the two parent.adoc files is which tag name is mentioned.  

:output_type: internal
include::child.adoc[tags={output_type}]

 Thanks
Reply | Threaded
Open this post in threaded view
|

Re: User-Defined Attribute in Include tags

mojavelinux
Administrator
Thank you for your question. Attribute references are not currently resolved in the attribute list of an include directive. However, I think it's reasonable to expect that they would be. This is an enhancement. Can you file an issue?

https://github.com/asciidoctor/asciidoctor/issues

The issue should not about tags at all, since that is just one possible usage of this functionality. The issue is whether attribute references are resolved in the attrlist of an include directive (in the same way that they are for block macros)

Cheers,

-Dan

On Sat, May 5, 2018 at 1:27 PM, zombi [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I have a need for a document to somewhat dynamically produce content based on the type of output document desired. For example, we have a document that will be used internally by our team as well as externally outside our team and while there is a high percentile of overlapping of information, not everything made available in the internal version of the document should be included in the external version of the document.

I have used Tags to help address this by having child .adoc files for all of the main content with includes statements in a parent.adoc that will produce the output based on those tags. Right now I have everything working, but I have to maintain two "parent" files that incorporate the includes of the child.adoc files; one for 'internal' and one for 'external'.

I'm wondering if there is a way to have an attribute defined in the parent document be used to specify the tag name in the include statement? Something like below so that I could update the output_type attribute and won't have to maintain two highly identical parent.adoc files. The only difference between the two parent.adoc files is which tag name is mentioned.  

:output_type: internal
include::child.adoc[tags={output_type}]

 Thanks


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/User-Defined-Attribute-in-Include-tags-tp6308.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
|

Re: User-Defined Attribute in Include tags

zombi
Thank you for confirming. I have submitted the ticket as requested.

https://github.com/asciidoctor/asciidoctor/issues/2761
Reply | Threaded
Open this post in threaded view
|

Re: User-Defined Attribute in Include tags

1marc1
In reply to this post by zombi
Zombi,

A workaround you could use in order to have just a single parent document would be to use the following in the parent file:

//Set :output_type: to "internal" or "external"
:output_type: internal

ifeval::["{output_type}" == "internal"]
include::child.adoc[tags=internal]
endif::[]

ifeval::["{output_type}" == "external"]
include::child.adoc[tags=external]
endif::[]

Marc.
Reply | Threaded
Open this post in threaded view
|

Re: User-Defined Attribute in Include tags

mojavelinux
Administrator
In reply to this post by zombi
Thanks @zombi.

-Dan

On Sun, May 6, 2018 at 8:00 AM, zombi [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thank you for confirming. I have submitted the ticket as requested.

https://github.com/asciidoctor/asciidoctor/issues/2761


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/User-Defined-Attribute-in-Include-tags-tp6308p6310.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