Can you let us know please in what kind of scenario you would like to add a HTML Snippet to another HTML Snippet?
The reason why I am asking this is because this is unfortunately not possible.
When inserting a HTML Snippet in a Print Context Section you have the option to insert it as Shared Content. This option is not available when inserting a HTML Snippet in another HTML Snippet.
I have 72 snippets, each containing a different text. They will most likely be remote snippets. For each document in the datamapper one of these 72 snippets will be loaded into my section with loadhtml.
In most of these snippets a couple of tables and some accompanying text has to be inserted. Since these tables and the text are always the same (although the data in the tables depends on the data of course), I have put those in snippet 2 which makes maintenance a breeze and which avoids them being altered by whoever alters the remote snippets.
If I could use snippet 2 inside the 68 remote snippets (as said, the tables don’t go in each of the 72 snippets) as I showed in my original question under “Snippet 1” that would make this whole setup plain and simple. Just load the right remote snippet and that’s it.
Workaround:
The workaround I have used now is far more complex:
The part of the 72 snippets before the table is always unique. The part after the tables is not. There are like 16 versions. So, now I have made 88 remote snippets (72 + 16)
In my section I have
And I have a Standard Script with selector article#RemHeader that first assembles a snippet name for the part of the letter before the table, based on a whole list of data fields and then loads it
var snippet = loadhtml(templateName);
if (snippet) {
results.replaceWith(snippet);
} else {
logger.error('template ' + templateName + ' does not exist');
}
Then I assemble the name of the table snippet and load that too. The line with results.replaceWith(snippet) is now replace however by
query('article#RemTable').replaceWith(snippet);
And lastly I do something similar for the third part of the letter.
It works this way, but my first idea was so much easier!