createDocumentFromLocalTemplate

Type: Function

How to get createDocumentFromLocalTemplate?

JavaScript

import createDocumentFromLocalTemplate from 'fontoxml-document-from-template/src/createDocumentFromLocalTemplate.js'

Creates a new document from a given template file and loads it.

The templates are required to be in 'assets/templates' and should be packaged in an appropriate feature package.

Note that Ids contained in the template will be regenerated, to ensure they are unique. This means it is impossible to use these ids in, for instance, crossreferences

Usage example:

Other

createDocumentFromLocalTemplate('my-template.xml', {
    modifyTemplateCallback: function modifyTemplate (documentNode, blueprint, format) {
  	   // Modify the document before it is sent to the CMS
  	   // The blueprint will be validated for you
    }
})
    .then(function (documentId) {
        // Do something useful with the documentId, which by now is loaded in the documentsManager
        // For example: add a reference to the DITA map or redirect to the editor route
    });

Arguments

  1. templateFilename

    (Required)

    Type: String

    The name of the template file from which to create the document. Must be in /assets/templates/.

  2. options

    (Optional)

    Type: Object

    Properties

Returns

Type: Promise<String>

Returns a promise which resolved to the documentId of the created document.