Comparing version 0.0.1 to 0.0.2
@@ -8,2 +8,6 @@ # Changelog | ||
## [0.0.2] - 2016-01-21 | ||
### Added | ||
- Layouts. | ||
## [0.0.1] - 2016-01-20 | ||
@@ -13,3 +17,4 @@ ### Added | ||
[Unreleased]: https://github.com/maxdeviant/greshunkel/compare/v0.0.1...HEAD | ||
[Unreleased]: https://github.com/maxdeviant/greshunkel/compare/v0.0.2...HEAD | ||
[0.0.2]: https://github.com/maxdeviant/greshunkel/compare/v0.0.1...v0.0.2 | ||
[0.0.1]: https://github.com/maxdeviant/greshunkel/compare/e8c19f3...v0.0.1 |
@@ -19,6 +19,18 @@ 'use strict'; | ||
return new Promise((resolve, reject) => { | ||
this._loadTemplate(template).then((content) => { | ||
content = this._interpolate(content, variables); | ||
variables = variables || {}; | ||
return resolve(content); | ||
let html; | ||
this._loadTemplate(template).then((templateHtml) => { | ||
html = templateHtml; | ||
return this._compileLayout(html); | ||
}).then((layoutHtml) => { | ||
if (layoutHtml) { | ||
html = layoutHtml; | ||
} | ||
html = this._interpolate(html, variables); | ||
return resolve(html); | ||
}).catch((err) => { | ||
@@ -30,4 +42,23 @@ return reject(err); | ||
_compileLayout(content) { | ||
return new Promise((resolve, reject) => { | ||
let pattern = /xXx\s*PARENT\s*=\s*([\w\/\.]+)\s*xXx/g; | ||
let match = pattern.exec(content); | ||
if (!match) { | ||
return resolve(content); | ||
} | ||
let layoutTag = new RegExp(match[0], 'g'); | ||
let layoutPath = match[1]; | ||
this._loadTemplate(layoutPath).then((layoutHtml) => { | ||
return resolve(layoutHtml); | ||
}); | ||
}); | ||
} | ||
_interpolate(content, variables) { | ||
let pattern = /xXx.*@([A-Za-z]+).*xXx/g; | ||
let pattern = /xXx\s*@([\w\/]+)\s*xXx/g; | ||
@@ -53,14 +84,14 @@ let match; | ||
return new Promise((resolve, reject) => { | ||
template = template.endsWith('.gshkl') ? template : template + '.gshkl'; | ||
template = this._appendFileExtension(template); | ||
let templatePath = path.join(this.options.directory, template); | ||
let reader = fs.createReadStream(templatePath, 'utf-8'); | ||
let content = ''; | ||
let html = ''; | ||
reader.on('data', (data) => { | ||
content += data; | ||
html += data; | ||
}); | ||
reader.on('close', () => { | ||
return resolve(content); | ||
return resolve(html); | ||
}); | ||
@@ -74,2 +105,6 @@ | ||
_appendFileExtension(filePath) { | ||
return filePath.endsWith('.gshkl') ? filePath : filePath + '.gshkl'; | ||
} | ||
} | ||
@@ -76,0 +111,0 @@ |
{ | ||
"name": "greshunkel", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A templating language for the V O I D.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./node_modules/mocha/bin/mocha" | ||
}, | ||
@@ -14,8 +14,8 @@ "repository": { | ||
"keywords": [ | ||
"html", | ||
"templating", | ||
"template", | ||
"merveilles", | ||
"void", | ||
"infoforcefeed", | ||
"merveilles", | ||
"template", | ||
"templating", | ||
"html" | ||
"infoforcefeed" | ||
], | ||
@@ -30,3 +30,7 @@ "author": "Marshall Bowers <elliott.codes@gmail.com>", | ||
"lodash": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.3.4", | ||
"should": "^8.1.1" | ||
} | ||
} |
# greshunkel | ||
[![forthebadge](http://forthebadge.com/images/badges/fuck-it-ship-it.svg)](http://forthebadge.com) | ||
[![Travis](https://img.shields.io/travis/maxdeviant/greshunkel.svg?style=flat-square)](https://travis-ci.org/maxdeviant/greshunkel) | ||
[![npm](https://img.shields.io/npm/v/greshunkel.svg?style=flat-square)](https://www.npmjs.com/package/greshunkel) | ||
Wally [requested](https://twitter.com/WAallLy/status/687059807518367744) this, so this is me delivering. | ||
@@ -7,4 +13,5 @@ | ||
- [x] Variable Interpolation | ||
- [x] Layouts | ||
## TODO | ||
- [ ] Implement everything in the [Greshunkel spec](http://38-moths.shithouse.tv/greshunkel.html) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
9880
22
168
1
17
2