-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d0f55db
Showing
13 changed files
with
4,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules | ||
.idea | ||
*.log | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"excludeFiles": [ | ||
"./**/node_modules/**", | ||
"./lib/vendors/**", | ||
"./browser/vendors/**", | ||
"./node_modules/**" | ||
], | ||
|
||
"requireCurlyBraces": [ | ||
"if", | ||
"else", | ||
"for", | ||
"while", | ||
"do", | ||
"try", | ||
"catch" | ||
], | ||
|
||
"requireSpaceBeforeBlockStatements": true, | ||
"requireParenthesesAroundIIFE": true, | ||
"requireSpacesInConditionalExpression": { | ||
"afterTest": true, | ||
"beforeConsequent": true, | ||
"afterConsequent": true, | ||
"beforeAlternate": true | ||
}, | ||
|
||
"requireSpacesInAnonymousFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInNamedFunctionExpression": { | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"disallowSpacesInNamedFunctionExpression": { | ||
"beforeOpeningRoundBrace": true | ||
}, | ||
|
||
"requireBlocksOnNewline": true, | ||
"disallowEmptyBlocks": true, | ||
"disallowSpacesInsideObjectBrackets": "all", | ||
"disallowSpacesInsideArrayBrackets": "all", | ||
"disallowSpacesInsideParentheses": true, | ||
"disallowQuotedKeysInObjects": true, | ||
"disallowSpaceAfterObjectKeys": true, | ||
"requireSpaceBeforeObjectValues": true, | ||
"requireCommaBeforeLineBreak": true, | ||
"requireOperatorBeforeLineBreak": true, | ||
"disallowSpaceAfterPrefixUnaryOperators": true, | ||
"disallowSpaceBeforePostfixUnaryOperators": true, | ||
"requireSpaceBeforeBinaryOperators": true, | ||
"requireSpaceAfterBinaryOperators": true, | ||
"disallowImplicitTypeConversion": [ | ||
"numeric", "boolean", "binary", "string" | ||
], | ||
"requireCamelCaseOrUpperCaseIdentifiers": true, | ||
"disallowKeywords": ["with", "let", "void"], | ||
"disallowMultipleLineBreaks": true, | ||
"disallowMixedSpacesAndTabs": true, | ||
"disallowTrailingWhitespace": true, | ||
"disallowTrailingComma": true, | ||
"disallowKeywordsOnNewLine": ["else", "catch"], | ||
"maximumLineLength": 80, | ||
"requireCapitalizedConstructors": true, | ||
"requireDotNotation": true, | ||
"disallowYodaConditions": true, | ||
"disallowNewlineBeforeBlockStatements": true, | ||
"validateLineBreaks": "LF", | ||
"validateQuoteMarks": "'", | ||
"validateIndentation": "\t", | ||
"validateParameterSeparator": ", ", | ||
"validateJSDoc": { | ||
"checkParamNames": true, | ||
"checkRedundantParams": true, | ||
"requireParamTypes": true | ||
}, | ||
"safeContextKeyword": ["self"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib/vendors | ||
browser/vendors | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"maxerr": 15, | ||
|
||
"nonew": true, | ||
"proto": true, | ||
"maxparams": 5, | ||
"maxdepth": 3, | ||
"maxstatements": 50, | ||
"maxcomplexity": 10, | ||
|
||
"globalstrict": true, | ||
|
||
"browser": false, | ||
"node": true, | ||
|
||
"globals": { | ||
"Promise": true, | ||
"window": true, | ||
"describe": true, | ||
"it": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node_modules | ||
.idea | ||
.git | ||
*.log | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2010 Aleksander Williams | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#Catberry Handlebars Adapter | ||
|
||
[](https://nodei.co/npm/catberry-handlebars/) | ||
|
||
It is an adapter for [Handlebars](http://handlebarsjs.com/) template engine | ||
that makes possible to use it from [Catberry](https://github.com/catberry/catberry) application. | ||
|
||
##Usage | ||
You can use the adapter like this in ./browser.js or ./server.js. | ||
Actually, [Catberry CLI](https://github.com/catberry/catberry-cli) does it for you. | ||
|
||
```javascript | ||
var handlebars = require('catberry-handlebars'), | ||
cat = catberry.create(config); | ||
handlebars.register(cat.locator); | ||
``` | ||
|
||
##Contribution | ||
If you have found a bug, please create pull request with [mocha](https://www.npmjs.org/package/mocha) | ||
unit-test which reproduces it or describe all details in an issue if you can not | ||
implement test. If you want to propose some improvements just create an issue or | ||
a pull request but please do not forget to use `npm test` to be sure that your | ||
code is awesome. | ||
|
||
All changes should satisfy this [Code Style Guide](https://github.com/catberry/catberry/blob/4.0.0/docs/code-style-guide.md). | ||
|
||
Also your changes should be covered by unit tests using [mocha](https://www.npmjs.org/package/mocha). | ||
|
||
Denis Rechkunov <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* catberry-handlebars | ||
* | ||
* Copyright (c) 2015 Denis Rechkunov and project contributors. | ||
* | ||
* catberry-handlebars's license follows: | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* This license applies to all parts of catberry-handlebars that are not externally | ||
* maintained libraries. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = TemplateProvider; | ||
|
||
/** | ||
* Creates new instance of Handlebars template provider. | ||
* @param {Handlebars} $handlebars Handlebars factory. | ||
* @constructor | ||
*/ | ||
function TemplateProvider($handlebars) { | ||
this._handlebars = $handlebars; | ||
this._templates = {}; | ||
} | ||
|
||
/** | ||
* Current Handlebars factory. | ||
* @type {Handlebars} | ||
* @private | ||
*/ | ||
TemplateProvider.prototype._handlebars = null; | ||
|
||
/** | ||
* Current set of registered templates. | ||
* @type {Object} | ||
* @private | ||
*/ | ||
TemplateProvider.prototype._templates = null; | ||
|
||
/** | ||
* Registers compiled (precompiled) Handlebars template. | ||
* http://handlebarsjs.com/reference.html | ||
* @param {String} name Template name. | ||
* @param {String} compiled Compiled template source. | ||
*/ | ||
TemplateProvider.prototype.registerCompiled = function (name, compiled) { | ||
this._templates[name] = this._handlebars.template(compiled); | ||
}; | ||
|
||
/** | ||
* Renders template with specified data. | ||
* @param {String} name Name of template. | ||
* @param {Object} data Data context for template. | ||
* @returns {*} | ||
*/ | ||
TemplateProvider.prototype.render = function (name, data) { | ||
if (!this._templates.hasOwnProperty(name)) { | ||
return Promise.reject(new Error('No such template')); | ||
} | ||
|
||
var promise; | ||
try { | ||
promise = Promise.resolve(this._templates[name](data)); | ||
} catch(e) { | ||
promise = Promise.reject(e); | ||
} | ||
return promise; | ||
}; |
Oops, something went wrong.