Dynamic snippets? Snippet as template?

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

Post Reply
Tony Starbuck
Posts: 10
Joined: Thu Feb 21, 2019 6:17 pm

Dynamic snippets? Snippet as template?

Unread post by Tony Starbuck » Tue May 19, 2020 4:49 pm

I've been through the forum and have found similar threads but they're all old.

I'm hoping to create a snippet that functions as a template, where text in the topic fills the gaps. Examples:
Download the %version version from %here.

The black bold text would be static while the dynamic %text would need to be replaced in the topic editor.
The snippet could later be modified to
The %version version can be downloaded %here.
With a single edit on the snippet, all topics would get the new static text without disturbing the dynamic text in each topic.

If I could ensure that a snippet is not wrapped at build time with markup, I could do something like this:

Code: Select all

<para><snippet src="file::text1.xml" inline="true"/>text1<snippet src="file::text2.xml" inline="true"/>text2<snippet src="file::text3.xml" inline="true"/></para>
So the three snippets can be changed, knowing that they will be rendered in order at build time. The problem there is that I did try to reduce the markup in one of those snippets, and on Save the markup was refreshed with a para tag and style. That also requires three snippet insertions per phrase, which is a pain.

I've read threads about dynamic text, user-defined variables, dynamic content generation with external code, etc. I can use whatever best practice is currently recommended - I just don't know what that is now.

BTW, we're running


User avatar
Tim Green
Site Admin
Posts: 21624
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany

Re: Dynamic snippets? Snippet as template?

Unread post by Tim Green » Tue May 19, 2020 6:45 pm

Hi Tony,
BTW, we're running
Not relevant for your question but you're way out of date and still have a lot of early bugs. The current build is 8.0.3 Build 5500. Please update asap:


Anything you edit in the XML will be thrown away silently if it doesn't conform exactly to the HM XML schema, which is documented in the Helpman_XML_ref.chm file, which you can find in the Help & Manual program directory. However, that won't really help you here because linked snippets don't work the way you are describing here. A snippet is an entire contiguous file and its reference in the topic editor is just that -- a reference to a full file. A linked snippet is shown in the topic editor, but that is just a preview. It's not editable. On publishing the current version of the referenced file is rendered and inserted in the output and becomes part of the output.

What you are thinking of here is something that combines the editable nature of a copy & pasted snippet with the live updating of a linked snippet, and that isn't available. You could use a copy & paste snippet like this but only once. As soon as it's pasted it becomes normal text with no reference to the source.
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.

Post Reply