diff --git a/ajax/libs/requirejs-tpl/0.0.2/tpl.js b/ajax/libs/requirejs-tpl/0.0.2/tpl.js new file mode 100644 index 000000000..38ccf4adb --- /dev/null +++ b/ajax/libs/requirejs-tpl/0.0.2/tpl.js @@ -0,0 +1,69 @@ +// RequireJS UnderscoreJS template plugin +// http://github.com/jfparadis/requirejs-tpl +// +// An alternative to http://github.com/ZeeAgency/requirejs-tpl +// +// Using UnderscoreJS micro-templates at http://underscorejs.org/#template +// Using and RequireJS text.js at http://requirejs.org/docs/api.html#text +// @author JF Paradis +// @version 0.0.2 +// +// Released under the MIT license +// +// Usage: +// require(['backbone', 'tpl!mytemplate'], function (Backbone, mytemplate) { +// return Backbone.View.extend({ +// initialize: function(){ +// this.render(); +// }, +// render: function(){ +// this.$el.html(mytemplate({message: 'hello'})); +// }); +// }); +// +// Configuration: (optional) +// require.config({ +// tpl: { +// extension: '.tpl' // default = '.html' +// } +// }); + +/*jslint nomen: true */ +/*global define: false */ + +define(['text', 'underscore'], function (text, _) { + 'use strict'; + + var buildMap = {}, + buildTemplateSource = "define('{pluginName}!{moduleName}', function () { return {source}; });\n"; + + return { + version: '0.0.2', + + load: function (moduleName, parentRequire, onload, config) { + if (buildMap[moduleName]) { + onload(buildMap[moduleName]); + + } else { + var ext = (config.tpl && config.tpl.extension) || '.html'; + var path = (config.tpl && config.tpl.path) || ''; + text.load(path + moduleName + ext, parentRequire, function (source) { + buildMap[moduleName] = _.template(source); + onload(buildMap[moduleName]); + }, config); + } + }, + + write: function (pluginName, moduleName, write) { + var build = buildMap[moduleName], + source = build && build.source; + if (source) { + write.asModule(pluginName + '!' + moduleName, + buildTemplateSource + .replace('{pluginName}', pluginName) + .replace('{moduleName}', moduleName) + .replace('{source}', source)); + } + } + }; +}); diff --git a/ajax/libs/requirejs-tpl/0.0.2/tpl.min.js b/ajax/libs/requirejs-tpl/0.0.2/tpl.min.js new file mode 100644 index 000000000..68b0746c3 --- /dev/null +++ b/ajax/libs/requirejs-tpl/0.0.2/tpl.min.js @@ -0,0 +1,13 @@ +// RequireJS UnderscoreJS template plugin +// http://github.com/jfparadis/requirejs-tpl +// +// An alternative to http://github.com/ZeeAgency/requirejs-tpl +// +// Using UnderscoreJS micro-templates at http://underscorejs.org/#template +// Using and RequireJS text.js at http://requirejs.org/docs/api.html#text +// @author JF Paradis +// @version 0.0.2 +// +// Released under the MIT license +define(["text","underscore"],function(text,_){var buildMap={},buildTemplateSource="define('{pluginName}!{moduleName}', function () { return {source}; });\n";return{version:"0.0.2",load:function(moduleName,parentRequire,onload,config){if(buildMap[moduleName])onload(buildMap[moduleName]);else{var ext=config.tpl&&config.tpl.extension||".html";var path=config.tpl&&config.tpl.path||"";text.load(path+moduleName+ext,parentRequire,function(source){buildMap[moduleName]=_.template(source);onload(buildMap[moduleName])}, +config)}},write:function(pluginName,moduleName,write){var build=buildMap[moduleName],source=build&&build.source;if(source)write.asModule(pluginName+"!"+moduleName,buildTemplateSource.replace("{pluginName}",pluginName).replace("{moduleName}",moduleName).replace("{source}",source))}}}); \ No newline at end of file diff --git a/ajax/libs/requirejs-tpl/package.json b/ajax/libs/requirejs-tpl/package.json new file mode 100644 index 000000000..84700968b --- /dev/null +++ b/ajax/libs/requirejs-tpl/package.json @@ -0,0 +1,27 @@ +{ + "name": "requirejs-tpl", + "filename": "tpl.js", + "version": "0.0.2", + "description": "A RequireJS/AMD loader plugin for Underscore.js micro-templates", + "homepage": "http://github.com/jfparadis/requirejs-tpl", + "keywords": [ + "require", + "requirejs", + "underscore", + "template" + ], + "maintainers": [ + { + "name": "jfparadis", + "email": "jf@jeanfrancoisparadis.com", + "web": "http://jeanfrancoisparadis.com/" + } + ], + "repositories": [ + { + "type": "git", + "url": "https://github.com/jfparadis/requirejs-tpl" + } + ] + +}