-
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 dc6c9c9
Showing
7 changed files
with
728 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,61 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
package-lock.json | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
public/app.js |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Vincent Racine, Graham Dixon | ||
|
||
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,35 @@ | ||
/** | ||
* Copyright (c) 2018 Graham Dixon | ||
* All rights reserved. (MIT Licensed) | ||
* | ||
* domvm-hbs-loader.js | ||
* this package compiles handlebar templates to JSX at build time | ||
* @preserve https://github.com/gdixon/domvm-hbs | ||
*/ | ||
|
||
// parser to convert hbs to hyperscript el calls | ||
const domvm_hbs = require('domvm-hbs'); | ||
|
||
// export the hbs file as callable hyperscript | ||
module.exports = function(content) { | ||
// allow the response to be cached | ||
this.cacheable = true; | ||
|
||
// options outside of the call | ||
const options = { | ||
'pragma': "el", | ||
raw: true | ||
}; | ||
|
||
// precompile the hbs to jsx (cant bind context yet) | ||
const precompile = domvm_hbs.compile(content, options); | ||
|
||
// locally scope the hbs runtime and jsx el function assigning the el fn to options | ||
const locallyScoped = "var domvm_hbs_runtime = require('domvm-hbs/lib/domvm-hbs-runtime'); var el = require('domvm-jsx'); var options = {el: el};"; | ||
|
||
// compile the hbs template before allowing it to repsond to vm calls - inline options and pragma fn | ||
return "module.exports = (function() { " + locallyScoped + " return " + precompile + ";})()"; | ||
} | ||
|
||
// run separate from the module system | ||
module.exports.seperable = 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,78 @@ | ||
/** | ||
* Copyright (c) 2018 Vincent Racine, Graham Dixon | ||
* All rights reserved. (MIT Licensed) | ||
* | ||
* domvm-hbs-runtime.js | ||
* this package compiles handlebar templates to JSX at build time (forked from vincentracine/hyperbars) | ||
* @preserve https://github.com/gdixon/domvm-hbs | ||
*/ | ||
|
||
module.exports = (function(domvm_hbs_runtime) { | ||
'use strict'; | ||
|
||
var domvm_hbs_runtime = {}; | ||
|
||
var isObject = function(a) { | ||
return Object.prototype.toString.call(a) === '[object Object]' | ||
}; | ||
|
||
domvm_hbs_runtime.prototype = { | ||
|
||
'setup': function(obj) { | ||
obj = obj || {}; | ||
}, | ||
|
||
/** | ||
* Register helpers | ||
*/ | ||
'registerHelper': function(name, handler) { | ||
domvm_hbs_runtime.methods[name] = handler; | ||
} | ||
}; | ||
|
||
domvm_hbs_runtime.methods = { | ||
'if': function(context, expression, callback) { | ||
if (expression.value) { | ||
return callback(isObject(expression.value) ? expression.value : context, context); | ||
} | ||
return ""; | ||
}, | ||
'unless': function(context, expression, callback) { | ||
if (!expression.value) { | ||
return callback(isObject(expression.value) ? expression.value : context, context); | ||
} | ||
return ""; | ||
}, | ||
'each': function(context, expression, callback) { | ||
return expression.value.map(function(item, index, array) { | ||
var options = {}; | ||
options['@index'] = index; | ||
options['@first'] = index == 0; | ||
options['@last'] = index == array.length - 1; | ||
return callback(item, context, options) | ||
}) | ||
}, | ||
/** | ||
* credit: http://stackoverflow.com/a/8625261/5678694 | ||
*/ | ||
'merge': function() { | ||
var obj = {}, | ||
i = 0, | ||
il = arguments.length, | ||
key; | ||
for (; i < il; i++) { | ||
for (key in arguments[i]) { | ||
if (arguments[i].hasOwnProperty(key)) { | ||
obj[key] = arguments[i][key]; | ||
} | ||
} | ||
} | ||
return obj; | ||
} | ||
}; | ||
|
||
return domvm_hbs_runtime; | ||
|
||
})(function() { | ||
this.debug = false; | ||
}); |
Oops, something went wrong.