-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f8af46
commit 7bbfa97
Showing
5 changed files
with
43 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ build/** | |
LICENSE | ||
*.html | ||
*.lock | ||
*.hbs | ||
*.handlebars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
function register() {} | ||
const geneasy = { | ||
register | ||
}; | ||
export default geneasy; | ||
import renderHbs from 'geneasy-handlebars'; | ||
import parse from 'geneasy-yaml'; | ||
import fsExtra from 'fs-extra'; | ||
|
||
const { readFile, writeFile } = fsExtra; | ||
|
||
export function register() {} | ||
export async function render(template, dataFiles, output) { | ||
const data = {}; | ||
const contents = await Promise.all( | ||
dataFiles.map((file) => readFile(file, 'utf-8').then((data) => parse(data))) | ||
); | ||
Object.assign(data, ...contents); | ||
template = await readFile(template, 'utf-8'); | ||
const result = await renderHbs(template, data); | ||
if (output) { | ||
await writeFile(output, result); | ||
} else { | ||
console.log(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters