Snippets

Select parts of existing topics as snippets, providing a snippet-id. Much like a context-id, the snippet-id must be unique within the current product-release-language space. The snippet-id cannot contain spaces or special characters.

Here is the json result returned by the snippet API: Snippet JSON

A consumer would parse the returned json and present the HTML found in the snippet field.

To specify existing content as a snippet

Markdown Example

Use the #style helper, with style snippet <snippet-id>.

For example:

{{#style "snippet snippets-contextid-one"}}
Some existing content that will be rendered here and returned by the snippet API call.
{{/style}} 

Some existing content that will be rendered here and returned by the snippet API call.

For the snippet defined above, the snippet API returns this json Snippet snippets-contextid-one

DITA

Enclose the snippet content in a section element and set the outputclass to snippet <snippet-id>.

For example:

<section outputclass="snippet snippet-contextid-42EA9825">
<p>
Add the <codeph>image</codeph> element and set the <codeph>outputclass</codeph> attribute to <codeph>card-thumbnail</codeph> and set the <codeph>visibility</codeph> attribute to <codeph>hide</codeph>.
</p>
</section>

For the snippet defined above, the snippet API returns this json Snippet snippet-contextid-42EA9825