Skip to content

Instantly share code, notes, and snippets.

@senthilp
Last active December 17, 2015 20:29
Show Gist options
  • Save senthilp/5668166 to your computer and use it in GitHub Desktop.
Save senthilp/5668166 to your computer and use it in GitHub Desktop.
/*
* Copyright 2011 eBay Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define.Class(
"raptor/packaging/Dependency_hbs",
"raptor/packaging/Dependency",
function(require, exports, module) {
"use strict";
var getHandlebarsOutput = function(templateSource, path) {
var hbs = require('handlebars'),
basename = require('path').basename,
templateName = basename(path),
output = [];
output.push('Handlebars.templates = Handlebars.templates || {}');
output.push('Handlebars.templates[\'' + templateName + '\'] = Handlebar.template(' + hbs.precompile(templateSource) + ');');
return output.join('\n');
};
var Dependency_hbs = function() {
Dependency_hbs.superclass.constructor.apply(this, arguments);
this.addProperty("path", {
type: "string"
});
};
Dependency_hbs.prototype = {
getKey: function() {
return "hbs:" + this.resolvePathKey(this.path);
},
toString: function() {
return this.getResource().getPath();
},
getCode: function(context) {
var resource = this.getResource(context);
var path = resource.getPath();
return getHandlebarsOutput(resource.readAsString("UTF-8"), path);
},
getResourcePath: function() {
return this.path;
},
getContentType: function() {
return "application/javascript";
},
isInPlaceDeploymentAllowed: function() {
return true;
},
load: function(context) {
var hbs = require('handlebars');
var resource = this.getResource(context);
hbs.compile(resource.readAsString("UTF-8"));
}
};
return Dependency_hbs;
});
"raptor": {
"taglibs": [
"/raptor/templating/taglibs/async/async.rtld",
"/raptor/templating/taglibs/caching/caching.rtld",
"/raptor/templating/taglibs/core/core.rtld",
"/raptor/templating/taglibs/html/html.rtld",
"/raptor/templating/taglibs/optimizer/optimizer.rtld",
"/raptor/templating/taglibs/widgets/widgets.rtld"
],
"module-mappings": {
"taglibs/core/compile-time": "/raptor/templating/taglibs/core/compile-time-package.json",
"taglibs/html/compile-time": "/raptor/templating/taglibs/html/compile-time-package.json",
"taglibs/widgets/compile-time": "/raptor/templating/taglibs/widgets/compile-time-package.json",
"taglibs/widgets": "/raptor/templating/taglibs/widgets/package.json"
},
"dependency-types": {
"js": "raptor/packaging/Dependency_js",
"css": "raptor/packaging/Dependency_css",
"dust": "raptor/packaging/Dependency_dust",
"hbs": "raptor/packaging/Dependency_hbs",
"less": "raptor/packaging/Dependency_less",
"4cc": "raptor/packaging/Dependency_4cc",
"module": "raptor/packaging/Dependency_module",
"package": "raptor/packaging/Dependency_package",
"rhtml": "raptor/packaging/Dependency_rhtml",
"coffee": "raptor/packaging/Dependency_coffee",
"rtld": "raptor/packaging/Dependency_rtld",
"resource": "raptor/packaging/Dependency_resource",
"loader-metadata": "raptor/packaging/Dependency_loader-metadata"
}
}
"dependencies": {
"uglify-js": "1.3.x",
"mime": "~1.2.7",
"sax": "~0.4.2",
"esprima": "~0.9.9",
"less": "~1.3.3",
"xmldom": "~0.1.13",
"optimist": "~0.3.5",
"sqwish": "~0.2.0",
"dustjs-linkedin": "~1.2.1",
"handlebars": "~1.0.11",
"rapido": ">=0.2.2",
"rapido-raptorjs": ">=0.2.2",
"coffee-script": ">=1.4.0",
"q": "~0.9.3"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment