{"id":23749423,"url":"https://github.com/data-forge/inflate-template","last_synced_at":"2025-07-15T06:41:21.523Z","repository":{"id":32830808,"uuid":"143597388","full_name":"data-forge/inflate-template","owner":"data-forge","description":"This library is responsible for exporting a 'data set' to a set of assets through a user-defined template. Provides the 'export' functionality of Data-Forge Plot.","archived":false,"fork":false,"pushed_at":"2023-01-12T09:27:17.000Z","size":259,"stargazers_count":1,"open_issues_count":6,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-16T16:09:44.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/data-forge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ashleydavis"}},"created_at":"2018-08-05T08:51:06.000Z","updated_at":"2021-10-02T00:51:14.000Z","dependencies_parsed_at":"2023-01-14T22:22:11.883Z","dependency_job_id":null,"html_url":"https://github.com/data-forge/inflate-template","commit_stats":null,"previous_names":["data-forge/export"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/data-forge/inflate-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-forge%2Finflate-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-forge%2Finflate-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-forge%2Finflate-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-forge%2Finflate-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/data-forge","download_url":"https://codeload.github.com/data-forge/inflate-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-forge%2Finflate-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265414707,"owners_count":23761056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-31T15:18:49.843Z","updated_at":"2025-07-15T06:41:21.480Z","avatar_url":"https://github.com/data-forge.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ashleydavis"],"categories":[],"sub_categories":[],"readme":"# inflate-template\n\nThis library is responsible for inflating a template with data. \n\nIt provides the 'export' functionality for [Data-Forge Plot](https://www.npmjs.com/package/data-forge-plot) and\n[Data-Forge Notebook](http://www.data-forge-notebook.com/).\n\n[Click here to support my work](https://www.codecapers.com.au/about#support-my-work)\n\n## Premise\n\nA template is any number of assets (text files, JS files, HTML files, etc) in a directory. Each asset is a Handlebars template that can be expanded by data.\n\nA template can be expanded in memory or expanded and written another directory on disk.\n\nThis library is used by Data-Forge Plot and Data-Forge Notebook to expand a data set into a web page, either in memory and then rendered to a PNG or PDF file or then exported to disk as a browser-based visualization.\n\n## Creating a template\n\nA template is a directory that contains template files that will be inflated with data when the template is expanded. Files to be inflated live under the 'assets' sub-directory in the template directory.\n\nThis repository contains an example template under the test-template directory. Please use this to understand the basics of how a template is constructed.\n\nA template can contain a template.json configuration file and a test-data.json. By convention files in the root directory or any other sub-directory other than the 'assets' sub-directory are not templates files, they can be configuration files, supporting files, build scripts, etc, but they are not inflated as part of the template.\n\n## Programmatic Usage\n\n# Installation\n\n    npm install --save inflate-template\n\n# Require\n\nJavaScript:\n\n    const { inflateTemplate, exportTemplate } = require('inflate-template');\n\nTypeScript:\n\n    import { inflateTemplate, exportTemplate } from 'inflate-template';\n\n# Usage\n\nExpand in memory:\n\n    const data = { /* ... your data to be expanded into the template ... */ }\n    const options = {\n        templatePath: \"\u003cpath-to-load-your-template-from\u003e\",\n    };\n    const template = await inflateTemplate(data, options);\n\n    console.log(template.files.length); // Print number of files in the template.\n\n    const fileContent = await template.files[0].expand(); // Expand first files content.\n\n    const outputPath = \"\u003cdirectory-to-export-expanded-template-to\u003e\";\n    await template.files[0].export(outputPath); // Export first file to output directory.\n\nExpand to disk:\n\n    const data = { /* ... your data to be expanded into the template ... */ }\n    const outputPath = \"\u003cdirectory-to-export-expanded-template-to\u003e\";\n    const options = {\n        templatePath: \"\u003cpath-to-load-your-template-from\"\u003e,\n    };\n    await exportTemplate(data, outputPath, options); // All expanded files are written to output directory.\n\n## Command line usage\n\nThis can also be used from the command line to test export templates.\n\nBefore using from the command line make sure your template contains a 'test-data.json' that is used to fill out the template.\n\nTo use from the command line please install globally like this:\n\n    npm install -g inflate-template\n\nYou can also omit the `-g` and just install locally, but then make sure you prefix all the subsequent commands with `npx`.\n\nTo inflate and export a template:\n\n    inflate-template export --template=\u003cpath-to-your-web-page-template\u003e --out=\"\u003cpath-to-output-your-expanded-template\u003e\"\n\nYou can also add the `--overwrite` argument to overite an existing export.\n\n### Template configuration\n\nThe file `template.json` can be used to configure a template:\n\n```json\n{\n    \"expand\": \"**/*\",\n    \"noExpand\": \"node_modules/\"\n}\n```\n\nAll fields are optional.\n\nFields can be arrays as well:\n\n```json\n{\n    \"expand\": [\"src/**/*\" ],\n    \"noExpand\": [ \"dist/\", \"node_modules/\" ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata-forge%2Finflate-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdata-forge%2Finflate-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata-forge%2Finflate-template/lists"}