// -----------------------------------------------------------------------------
$templateName = 'template-2-text-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
// -----------------------------------------------------------------------------
$templateName = 'template-block-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
printf('%sBlock names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$blockNames = $mailMerge->getBlockNames();
foreach ($blockNames as $blockName) {
    printf('- %s%s', $blockName, PHP_EOL);
}
printf('%sBlock field names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
foreach ($blockNames as $blockName) {
    $blockFieldNames = $mailMerge->getBlockFieldNames($blockName);
    foreach ($blockFieldNames as $blockFieldName) {
        printf('- %s::%s%s', $blockName, $blockFieldName, PHP_EOL);
    }
}
print PHP_EOL;
// -----------------------------------------------------------------------------
unset($mailMerge);