rename templates in .hbs

This commit is contained in:
Jonathan Rainville 2018-10-17 16:18:24 -04:00 committed by Pascal Precht
parent c2eaa80923
commit 529edaa058
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
5 changed files with 6 additions and 4 deletions

View File

@ -89,13 +89,13 @@ class ScaffoldingReact {
try { try {
const filename = contract.className.toLowerCase(); const filename = contract.className.toLowerCase();
this._generateFile(contract, 'index.html.tpl', 'html', this._generateFile(contract, 'index.html.hbs', 'html',
{ {
'title': contract.className, 'title': contract.className,
filename filename
}, overwrite); }, overwrite);
const filePath = this._generateFile(contract, 'dapp.js.tpl', 'js', const filePath = this._generateFile(contract, 'dapp.js.hbs', 'js',
{ {
'title': contract.className, 'title': contract.className,
'contractName': contract.className, 'contractName': contract.className,

View File

@ -1,6 +1,7 @@
const Handlebars = require('handlebars'); const Handlebars = require('handlebars');
const fs = require('../../core/fs'); const fs = require('../../core/fs');
const utils = require('../../utils/utils');
const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1); const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
@ -20,11 +21,12 @@ class ScaffoldingSolidity {
throw new Error("file '" + filePath + "' already exists"); throw new Error("file '" + filePath + "' already exists");
} }
const templatePath = fs.embarkPath('lib/modules/scaffolding-solidity/templates/' + templateFilename); const templatePath = utils.joinPath(__dirname, 'templates/' + templateFilename);
const source = fs.readFileSync(templatePath).toString(); const source = fs.readFileSync(templatePath).toString();
const template = Handlebars.compile(source); const template = Handlebars.compile(source);
// Write template // Write template
console.dir(data);
const result = template(data); const result = template(data);
fs.writeFileSync(filePath, result); fs.writeFileSync(filePath, result);
return filePath; return filePath;
@ -36,7 +38,7 @@ class ScaffoldingSolidity {
const filename = contract.className; const filename = contract.className;
const filePath = this._generateFile(contract, 'contract.sol.tpl', 'sol', { const filePath = this._generateFile(contract, 'contract.sol.hbs', 'sol', {
'contractName': contract.className, 'contractName': contract.className,
'structName': contract.className + "Struct", 'structName': contract.className + "Struct",
'fields': Object.keys(contract.fields).map(f => { 'fields': Object.keys(contract.fields).map(f => {