Show values in output
This commit is contained in:
parent
1402b04b51
commit
3e7f6168ca
4 changed files with 14 additions and 5 deletions
12
index.ts
12
index.ts
|
@ -59,6 +59,13 @@ function writeTemplate(
|
||||||
writeFileSync(outputFile, template(context));
|
writeFileSync(outputFile, template(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function humanize(value: number) {
|
||||||
|
if (isPrecision(value, 0)) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
return value.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
rimraf.sync(BUILD_DIR);
|
rimraf.sync(BUILD_DIR);
|
||||||
|
|
||||||
|
@ -94,7 +101,8 @@ function writeTemplate(
|
||||||
const value = parseFloat(i.toFixed(2));
|
const value = parseFloat(i.toFixed(2));
|
||||||
const context = {
|
const context = {
|
||||||
...baseContext,
|
...baseContext,
|
||||||
value: value.toFixed(2),
|
displayValue: "£" + humanize(value),
|
||||||
|
value: humanize(value)
|
||||||
};
|
};
|
||||||
writeTemplate(template, value.toString(), context);
|
writeTemplate(template, value.toString(), context);
|
||||||
if (isPrecision(value, 1)) {
|
if (isPrecision(value, 1)) {
|
||||||
|
@ -106,7 +114,7 @@ function writeTemplate(
|
||||||
}
|
}
|
||||||
bar.tick();
|
bar.tick();
|
||||||
});
|
});
|
||||||
writeTemplate(template, '', { ...baseContext, value: '' });
|
writeTemplate(template, '', { ...baseContext, displayValue: 'money' });
|
||||||
const filesOutput = glob.sync(join(BUILD_DIR, '**/index.html')).length;
|
const filesOutput = glob.sync(join(BUILD_DIR, '**/index.html')).length;
|
||||||
console.log(`Generated ${filesOutput} files.`);
|
console.log(`Generated ${filesOutput} files.`);
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"build": "ts-node index.ts",
|
"build": "ts-node index.ts",
|
||||||
"lint": "tsc --noEmit --project tsconfig.json && tslint --project tsconfig.json index.ts",
|
"lint": "tsc --noEmit --project tsconfig.json && tslint --project tsconfig.json index.ts",
|
||||||
"prettier": "prettier --write index.ts",
|
"prettier": "prettier --write index.ts",
|
||||||
"start": "http-server build/"
|
"start": "http-server build/ -c-1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="card-deck">
|
<div class="card-deck">
|
||||||
{{#each accounts }}
|
{{#each accounts }}
|
||||||
<div class="card text-center mx-5">
|
<div class="card text-center mx-5">
|
||||||
<a href="{{ link }}" class="colour-invert">
|
<a href="{{ link }}/{{ ../value }}" class="colour-invert">
|
||||||
<img src="{{ image }}" class="card-img-top my-3 mx-3" alt="{{ name }} logo" style="max-width:40%" />
|
<img src="{{ image }}" class="card-img-top my-3 mx-3" alt="{{ name }} logo" style="max-width:40%" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css" />
|
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css" />
|
||||||
<link rel="stylesheet" href="../node_modules/animate.css/animate.min.css" />
|
<link rel="stylesheet" href="../node_modules/animate.css/animate.min.css" />
|
||||||
<link rel="stylesheet" href="./index.scss" />
|
<link rel="stylesheet" href="./index.scss" />
|
||||||
|
<title>Give {{ displayValue }} to me</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="jumbotron mb-0 jumbotron-fluid text-center vertical-center">
|
<div class="jumbotron mb-0 jumbotron-fluid text-center vertical-center">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="display-1"></h1>
|
<h1 class="display-1"></h1>
|
||||||
<p class="lead">You should give me money. Here's how:</p>
|
<p class="lead">You should give me {{ displayValue }}. Here's how:</p>
|
||||||
<h1>
|
<h1>
|
||||||
<i class="fas fa-chevron-down mt-5 animated infinite slideInDown"></i>
|
<i class="fas fa-chevron-down mt-5 animated infinite slideInDown"></i>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
Reference in a new issue