UNPKG

alpaca

Version:

Alpaca provides the easiest and fastest way to generate interactive forms for the web and mobile devices. It runs simply as HTML5 or more elaborately using Bootstrap, jQuery Mobile or jQuery UI. Alpaca uses Handlebars to process JSON schema and provide

59 lines (47 loc) 1.42 kB
(function() { Alpaca.TemplateEngineRegistry = (function() { var registry = {}; return { register: function(id, engine) { registry[id] = engine; engine.init(); }, find: function(idOrType) { var engine = null; if (registry[idOrType]) { engine = registry[idOrType]; } else { // inspect by type for (var id in registry) { var supportedMimetypes = registry[id].supportedMimetypes(); for (var i = 0; i < supportedMimetypes.length; i++) { if (idOrType.toLowerCase() === supportedMimetypes[i].toLowerCase()) { engine = registry[id]; break; } } } } return engine; }, ids: function() { var ids = []; for (var id in registry) { ids.push(id); } return ids; } }; })(); })();