diff --git a/index.ts b/index.ts index 83c0eb9..6e7ff29 100644 --- a/index.ts +++ b/index.ts @@ -59,6 +59,13 @@ function writeTemplate( writeFileSync(outputFile, template(context)); } +function humanize(value: number) { + if (isPrecision(value, 0)) { + return value.toString(); + } + return value.toFixed(2); +} + (async function() { rimraf.sync(BUILD_DIR); @@ -94,7 +101,8 @@ function writeTemplate( const value = parseFloat(i.toFixed(2)); const context = { ...baseContext, - value: value.toFixed(2), + displayValue: "£" + humanize(value), + value: humanize(value) }; writeTemplate(template, value.toString(), context); if (isPrecision(value, 1)) { @@ -106,7 +114,7 @@ function writeTemplate( } bar.tick(); }); - writeTemplate(template, '', { ...baseContext, value: '' }); + writeTemplate(template, '', { ...baseContext, displayValue: 'money' }); const filesOutput = glob.sync(join(BUILD_DIR, '**/index.html')).length; console.log(`Generated ${filesOutput} files.`); })(); diff --git a/package.json b/package.json index 3fdf748..d04c3a2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "ts-node index.ts", "lint": "tsc --noEmit --project tsconfig.json && tslint --project tsconfig.json index.ts", "prettier": "prettier --write index.ts", - "start": "http-server build/" + "start": "http-server build/ -c-1" }, "repository": { "type": "git", diff --git a/src/accounts.html b/src/accounts.html index e14e87d..575391c 100644 --- a/src/accounts.html +++ b/src/accounts.html @@ -3,7 +3,7 @@
{{#each accounts }}
- + {{ name }} logo
diff --git a/src/template.html b/src/template.html index 0fc0e46..093bc97 100644 --- a/src/template.html +++ b/src/template.html @@ -3,12 +3,13 @@ + Give {{ displayValue }} to me

-

You should give me money. Here's how:

+

You should give me {{ displayValue }}. Here's how: