initial
This commit is contained in:
		
							
								
								
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					node_modules/
 | 
				
			||||||
 | 
					coverage/
 | 
				
			||||||
 | 
					public/
 | 
				
			||||||
 | 
					pages/
 | 
				
			||||||
 | 
					.nogit/
 | 
				
			||||||
							
								
								
									
										4
									
								
								.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.npmignore
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					coverage/
 | 
				
			||||||
 | 
					node_modules/
 | 
				
			||||||
 | 
					test/
 | 
				
			||||||
 | 
					ts/
 | 
				
			||||||
							
								
								
									
										38
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					# smarthbs
 | 
				
			||||||
 | 
					handlebars with better fs support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Availabililty
 | 
				
			||||||
 | 
					[](https://www.npmjs.com/package/smarthbs)
 | 
				
			||||||
 | 
					[](https://GitLab.com/pushrocks/smarthbs)
 | 
				
			||||||
 | 
					[](https://github.com/pushrocks/smarthbs)
 | 
				
			||||||
 | 
					[](https://pushrocks.gitlab.io/smarthbs/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Status for master
 | 
				
			||||||
 | 
					[](https://GitLab.com/pushrocks/smarthbs/commits/master)
 | 
				
			||||||
 | 
					[](https://GitLab.com/pushrocks/smarthbs/commits/master)
 | 
				
			||||||
 | 
					[](https://www.npmjs.com/package/smarthbs)
 | 
				
			||||||
 | 
					[](https://david-dm.org/pushrocks/smarthbs)
 | 
				
			||||||
 | 
					[](https://www.bithound.io/github/pushrocks/smarthbs/master/dependencies/npm)
 | 
				
			||||||
 | 
					[](https://www.bithound.io/github/pushrocks/smarthbs)
 | 
				
			||||||
 | 
					[](https://nodejs.org/dist/latest-v6.x/docs/api/)
 | 
				
			||||||
 | 
					[](https://nodejs.org/dist/latest-v6.x/docs/api/)
 | 
				
			||||||
 | 
					[](http://standardjs.com/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Usage
 | 
				
			||||||
 | 
					Use TypeScript for best in class instellisense.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> Note: Why did we decide against a class based architecture?  
 | 
				
			||||||
 | 
					Easy: handlebars.js is already pretty determined how things are handled internally, namely a global partial template registry
 | 
				
			||||||
 | 
					It doesn't make sense to then introduce a scoped partial template approach.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```javascript
 | 
				
			||||||
 | 
					import * as smarthbs from 'smarthbs'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// read all .hbs files in a directory and any child directories and use relative path as partial string identifier
 | 
				
			||||||
 | 
					smarthbs.registerPartialDir(testPartialDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// read all .hbs files in a particular directory and level, output them to a destination and specify a .json file to read any referenced data
 | 
				
			||||||
 | 
					smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json')
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[](https://push.rocks)
 | 
				
			||||||
							
								
								
									
										4
									
								
								dist/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								dist/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					import 'typings-global';
 | 
				
			||||||
 | 
					export declare type TTemplateStringType = 'filePath' | 'code';
 | 
				
			||||||
 | 
					export declare let registerPartialDir: (dirPathArg: string) => void;
 | 
				
			||||||
 | 
					export declare let compileDirectory: (originDirPathArg: string, destinationDirPathArg: string, dataFileNameArg: string) => void;
 | 
				
			||||||
							
								
								
									
										31
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					"use strict";
 | 
				
			||||||
 | 
					require("typings-global");
 | 
				
			||||||
 | 
					const handlebars = require("handlebars");
 | 
				
			||||||
 | 
					const smartfile = require("smartfile");
 | 
				
			||||||
 | 
					const path = require("path");
 | 
				
			||||||
 | 
					exports.registerPartialDir = (dirPathArg) => {
 | 
				
			||||||
 | 
					    smartfile.fs.listFileTree(dirPathArg, '**/*.hbs').then(hbsFileArrayArg => {
 | 
				
			||||||
 | 
					        for (let hbsFilePath of hbsFileArrayArg) {
 | 
				
			||||||
 | 
					            let parsedPath = path.parse(hbsFilePath);
 | 
				
			||||||
 | 
					            let hbsFileString = smartfile.fs.toStringSync(path.join(dirPathArg, hbsFilePath));
 | 
				
			||||||
 | 
					            if (parsedPath.dir === '') {
 | 
				
			||||||
 | 
					                parsedPath.name = '/' + parsedPath.name;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            let partialName = `partials${parsedPath.dir}${parsedPath.name}`;
 | 
				
			||||||
 | 
					            handlebars.registerPartial(partialName, hbsFileString);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					exports.compileDirectory = (originDirPathArg, destinationDirPathArg, dataFileNameArg) => {
 | 
				
			||||||
 | 
					    let hbsFilePathArray = smartfile.fs.listFilesSync(originDirPathArg, /.hbs/);
 | 
				
			||||||
 | 
					    let data = smartfile.fs.toObjectSync(path.join(originDirPathArg, dataFileNameArg));
 | 
				
			||||||
 | 
					    for (let hbsFilePath of hbsFilePathArray) {
 | 
				
			||||||
 | 
					        let parsedPath = path.parse(hbsFilePath);
 | 
				
			||||||
 | 
					        let hbsFileString = smartfile.fs.toStringSync(path.join(originDirPathArg, hbsFilePath));
 | 
				
			||||||
 | 
					        let template = handlebars.compile(hbsFileString);
 | 
				
			||||||
 | 
					        let output = template(data);
 | 
				
			||||||
 | 
					        console.log('hi ' + output + ' hi');
 | 
				
			||||||
 | 
					        smartfile.memory.toFsSync(output, path.join(destinationDirPathArg, parsedPath.name + '.html'));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLHlDQUF3QztBQUN4Qyx1Q0FBc0M7QUFDdEMsNkJBQTRCO0FBR2pCLFFBQUEsa0JBQWtCLEdBQUcsQ0FBQyxVQUFrQjtJQUMvQyxTQUFTLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQyxVQUFVLEVBQUUsVUFBVSxDQUFDLENBQUMsSUFBSSxDQUFDLGVBQWU7UUFDbEUsR0FBRyxDQUFDLENBQUMsSUFBSSxXQUFXLElBQUksZUFBZSxDQUFDLENBQUMsQ0FBQztZQUN0QyxJQUFJLFVBQVUsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1lBQ3hDLElBQUksYUFBYSxHQUFHLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUE7WUFDakYsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDLEdBQUcsS0FBSyxFQUFFLENBQUMsQ0FBQyxDQUFDO2dCQUN4QixVQUFVLENBQUMsSUFBSSxHQUFHLEdBQUcsR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFBO1lBQzNDLENBQUM7WUFDRCxJQUFJLFdBQVcsR0FBRyxXQUFXLFVBQVUsQ0FBQyxHQUFHLEdBQUcsVUFBVSxDQUFDLElBQUksRUFBRSxDQUFBO1lBQy9ELFVBQVUsQ0FBQyxlQUFlLENBQUMsV0FBVyxFQUFFLGFBQWEsQ0FBQyxDQUFBO1FBQzFELENBQUM7SUFDTCxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQTtBQUVVLFFBQUEsZ0JBQWdCLEdBQUcsQ0FDMUIsZ0JBQXdCLEVBQ3hCLHFCQUE2QixFQUM3QixlQUF1QjtJQUV2QixJQUFJLGdCQUFnQixHQUFHLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLGdCQUFnQixFQUFFLE1BQU0sQ0FBQyxDQUFBO0lBQzNFLElBQUksSUFBSSxHQUFHLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLEVBQUUsZUFBZSxDQUFDLENBQUMsQ0FBQTtJQUNsRixHQUFHLENBQUEsQ0FBQyxJQUFJLFdBQVcsSUFBSSxnQkFBZ0IsQ0FBQyxDQUFDLENBQUM7UUFDdEMsSUFBSSxVQUFVLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUN4QyxJQUFJLGFBQWEsR0FBRyxTQUFTLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLGdCQUFnQixFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUE7UUFDdkYsSUFBSSxRQUFRLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUNoRCxJQUFJLE1BQU0sR0FBRyxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDM0IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxLQUFLLEdBQUcsTUFBTSxHQUFHLEtBQUssQ0FBQyxDQUFBO1FBQ25DLFNBQVMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFDLHFCQUFxQixFQUFFLFVBQVUsQ0FBQyxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQTtJQUNsRyxDQUFDO0FBQ0wsQ0FBQyxDQUFBIn0=
 | 
				
			||||||
							
								
								
									
										33
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "smarthbs",
 | 
				
			||||||
 | 
					  "version": "1.0.2",
 | 
				
			||||||
 | 
					  "description": "handlebars with better fs support",
 | 
				
			||||||
 | 
					  "main": "dist/index.js",
 | 
				
			||||||
 | 
					  "typings": "dist/index.d.ts",
 | 
				
			||||||
 | 
					  "scripts": {
 | 
				
			||||||
 | 
					    "test": "(npmts)"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "repository": {
 | 
				
			||||||
 | 
					    "type": "git",
 | 
				
			||||||
 | 
					    "url": "git+ssh://git@gitlab.com/pkunz/smarthbs.git"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "keywords": [
 | 
				
			||||||
 | 
					    "handlebars"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "author": "Lossless GmbH",
 | 
				
			||||||
 | 
					  "license": "MIT",
 | 
				
			||||||
 | 
					  "bugs": {
 | 
				
			||||||
 | 
					    "url": "https://gitlab.com/pkunz/smarthbs/issues"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "homepage": "https://gitlab.com/pkunz/smarthbs#README",
 | 
				
			||||||
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
					    "@types/handlebars": "^4.0.31",
 | 
				
			||||||
 | 
					    "handlebars": "^4.0.6",
 | 
				
			||||||
 | 
					    "smartfile": "^4.1.4",
 | 
				
			||||||
 | 
					    "smartq": "^1.0.4",
 | 
				
			||||||
 | 
					    "typings-global": "^1.0.14"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "devDependencies": {
 | 
				
			||||||
 | 
					    "typings-test": "^1.0.3"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/hbs_testfiles/data.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/hbs_testfiles/data.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					{}
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/hbs_testfiles/index.hbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/hbs_testfiles/index.hbs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					{{> partials/header}}
 | 
				
			||||||
							
								
								
									
										0
									
								
								test/hbs_testfiles/partials/footer.hbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/hbs_testfiles/partials/footer.hbs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								test/hbs_testfiles/partials/header.hbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/hbs_testfiles/partials/header.hbs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					<head></head>
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/test.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/test.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					import 'typings-test';
 | 
				
			||||||
							
								
								
									
										16
									
								
								test/test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/test.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					"use strict";
 | 
				
			||||||
 | 
					require("typings-test");
 | 
				
			||||||
 | 
					const smarthbs = require("../dist/index");
 | 
				
			||||||
 | 
					const path = require("path");
 | 
				
			||||||
 | 
					let testHbsDir = path.join(__dirname, 'hbs_testfiles');
 | 
				
			||||||
 | 
					let testPartialDir = path.join(testHbsDir, 'partials');
 | 
				
			||||||
 | 
					let testResultDir = path.join(__dirname, 'testresult');
 | 
				
			||||||
 | 
					describe('smarthbs', function () {
 | 
				
			||||||
 | 
					    it('should create partials', function () {
 | 
				
			||||||
 | 
					        smarthbs.registerPartialDir(testPartialDir);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    it('should compile a directory', function () {
 | 
				
			||||||
 | 
					        smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiwwQ0FBeUM7QUFDekMsNkJBQTRCO0FBRTVCLElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLGVBQWUsQ0FBQyxDQUFBO0FBQ3RELElBQUksY0FBYyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLFVBQVUsQ0FBQyxDQUFBO0FBQ3RELElBQUksYUFBYSxHQUFHLElBQUksQ0FBRSxJQUFJLENBQUMsU0FBUyxFQUFFLFlBQVksQ0FBQyxDQUFBO0FBQ3ZELFFBQVEsQ0FBQyxVQUFVLEVBQUU7SUFFakIsRUFBRSxDQUFDLHdCQUF3QixFQUFFO1FBQ3pCLFFBQVEsQ0FBQyxrQkFBa0IsQ0FBQyxjQUFjLENBQUMsQ0FBQTtJQUMvQyxDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQyw0QkFBNEIsRUFBRTtRQUM3QixRQUFRLENBQUMsZ0JBQWdCLENBQUMsVUFBVSxFQUFFLGFBQWEsRUFBRSxXQUFXLENBQUMsQ0FBQTtJQUNyRSxDQUFDLENBQUMsQ0FBQTtBQUVOLENBQUMsQ0FBQyxDQUFBIn0=
 | 
				
			||||||
							
								
								
									
										18
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					import 'typings-test'
 | 
				
			||||||
 | 
					import * as smarthbs from '../dist/index'
 | 
				
			||||||
 | 
					import * as path from 'path'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let testHbsDir = path.join(__dirname, 'hbs_testfiles')
 | 
				
			||||||
 | 
					let testPartialDir = path.join(testHbsDir, 'partials')
 | 
				
			||||||
 | 
					let testResultDir = path .join(__dirname, 'testresult')
 | 
				
			||||||
 | 
					describe('smarthbs', function() {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    it('should create partials', function(){
 | 
				
			||||||
 | 
					        smarthbs.registerPartialDir(testPartialDir)
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should compile a directory', function() {
 | 
				
			||||||
 | 
					        smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json')
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/testresult/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/testresult/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					<head></head>
 | 
				
			||||||
							
								
								
									
										36
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					import 'typings-global'
 | 
				
			||||||
 | 
					import * as handlebars from 'handlebars'
 | 
				
			||||||
 | 
					import * as smartfile from 'smartfile'
 | 
				
			||||||
 | 
					import * as path from 'path'
 | 
				
			||||||
 | 
					export type TTemplateStringType = 'filePath' | 'code'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let registerPartialDir = (dirPathArg: string) => {
 | 
				
			||||||
 | 
					    smartfile.fs.listFileTree(dirPathArg, '**/*.hbs').then(hbsFileArrayArg => {
 | 
				
			||||||
 | 
					        for (let hbsFilePath of hbsFileArrayArg) {
 | 
				
			||||||
 | 
					            let parsedPath = path.parse(hbsFilePath)
 | 
				
			||||||
 | 
					            let hbsFileString = smartfile.fs.toStringSync(path.join(dirPathArg, hbsFilePath))
 | 
				
			||||||
 | 
					            if (parsedPath.dir === '') {
 | 
				
			||||||
 | 
					                parsedPath.name = '/' + parsedPath.name
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            let partialName = `partials${parsedPath.dir}${parsedPath.name}`
 | 
				
			||||||
 | 
					            handlebars.registerPartial(partialName, hbsFileString)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let compileDirectory = (
 | 
				
			||||||
 | 
					    originDirPathArg: string,
 | 
				
			||||||
 | 
					    destinationDirPathArg: string,
 | 
				
			||||||
 | 
					    dataFileNameArg: string
 | 
				
			||||||
 | 
					) => {
 | 
				
			||||||
 | 
					    let hbsFilePathArray = smartfile.fs.listFilesSync(originDirPathArg, /.hbs/)
 | 
				
			||||||
 | 
					    let data = smartfile.fs.toObjectSync(path.join(originDirPathArg, dataFileNameArg))
 | 
				
			||||||
 | 
					    for(let hbsFilePath of hbsFilePathArray) {
 | 
				
			||||||
 | 
					        let parsedPath = path.parse(hbsFilePath)
 | 
				
			||||||
 | 
					        let hbsFileString = smartfile.fs.toStringSync(path.join(originDirPathArg, hbsFilePath))
 | 
				
			||||||
 | 
					        let template = handlebars.compile(hbsFileString)
 | 
				
			||||||
 | 
					        let output = template(data)
 | 
				
			||||||
 | 
					        console.log('hi ' + output + ' hi')
 | 
				
			||||||
 | 
					        smartfile.memory.toFsSync(output, path.join(destinationDirPathArg, parsedPath.name + '.html'))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user