@formfeed/devkit 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @formfeed/devkit
13
13
  ```ts
14
14
  import { defaultData, diagnose, projectAround, readTemplate, renderLocal } from '@formfeed/devkit';
15
15
 
16
- // a folder with template.html, template.json, styles.css, data/*.json (see the project layout docs)
16
+ // a folder with template.html, template.json, style.css, data/*.json (see the project layout docs)
17
17
  const project = projectAround('templates/invoice-de');
18
18
  const tpl = readTemplate(project, 'invoice-de');
19
19
  const { data } = defaultData(tpl); // data/default.json, or the first data set
@@ -22,7 +22,22 @@ console.log(diagnose(tpl, data)); // the editor's diagnostics: syntax errors, un
22
22
  const { document } = await renderLocal(project, tpl, data, { mode: 'print' }); // complete HTML, no browser
23
23
  ```
24
24
 
25
- Errors are `DevkitError` instances with a `code`, which the CLI maps to its exit codes.
25
+ A folder can hold a Word or PowerPoint document (`template.docx` or `template.pptx`) instead of the
26
+ HTML files; `readTemplate` returns it as `tpl.file` and `templateFileName(kind)` names the file for
27
+ a kind. `diagnose` lists such a template's findings by part and paragraph, `renderOfficeLocal` fills
28
+ it (`bytes`, `warnings`) and `officeSnapshot(bytes)` turns the filled file into readable XML for
29
+ snapshot tests:
30
+
31
+ ```ts
32
+ import { officeSnapshot, readTemplate, renderOfficeLocal } from '@formfeed/devkit';
33
+
34
+ const offer = readTemplate(project, 'offer');
35
+ const filled = await renderOfficeLocal(project, offer, { customer: { name: 'Olvarest GmbH' } });
36
+ console.log(filled.warnings, officeSnapshot(filled.bytes));
37
+ ```
38
+
39
+ `renderLocal` works on HTML templates only. Errors are `DevkitError` instances with a `code`, which
40
+ the CLI maps to its exit codes.
26
41
 
27
42
  ## Documentation
28
43