Writerside Help

Conditional content

You can include or exclude pieces of content based on certain conditions, such as product, version, audience, operating system, or relevant technology.

Filter by instance

If a topic is in several instances, you can specify elements that should or should not be included when building a specific instance.

  • Add the instance attribute to any element and list the instances separated by commas in which this element should be included. If you want to exclude an element from some instances, use !.

    <chapter title="Included everywhere" id="included_everywhere"> <p>This chapter and paragraph is included everywhere.</p> <if instance="foo,bar"> <p>This paragraph and the following image is filtered for instances `foo` and `bar`.</p> <img src="image.png" alt="Image"/> </if> </chapter> <chapter title="Excluded from `foo`" id="excluded_from_foo_" instance="!foo"> <p> This chapter is excluded from the instance `foo`. <if instance="bar">And this part of the paragraph is included only in `bar`.</if> </p> </chapter>
    ## Included everywhere This chapter and paragraph is included everywhere. <if instance="foo,bar"> This paragraph and the following image is filtered for instances `foo` and `bar`. ![Image](image.png) </if> ## Excluded from `foo` {instance="!foo"} This chapter is excluded from the instance `foo`. <if instance="bar">And this part of the paragraph is included only in `bar`.</if>

Filter included content by custom conditions

When you include a snippet, you can specify custom filters that should apply for this specific include.

  1. Add the filter attribute to any element in the snippet and specify a comma-separated list of custom filters.

    <snippet id="os_dependent_procedure_steps"> <step>Do this first</step> <step filter="macos">Step for macOS</step> <step filter="windows">Step for Windows</step> </snippet>
  2. Add the use-filter attribute when including the snippet.

    <procedure title="Install on macOS" id="install"> <include from="lib.topic" element-id="os_dependent_procedure_steps" use-filter="empty,macos"/> </procedure> <procedure title="Install on Windows" id="install"> <include from="lib.topic" element-id="os_dependent_procedure_steps" use-filter="empty,windows"/> </procedure>
Last modified: 14 May 2024