Lungo.View.Template.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Lungo Template system
  3. *
  4. * @namespace LUNGO.View
  5. * @class Template
  6. * @requires Zepto
  7. *
  8. * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
  9. * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
  10. */
  11. LUNGO.View.Template = (function(undefined) {
  12. var _templates = {};
  13. /**
  14. * Create a new databinding template based on a <markup>
  15. *
  16. * @method create
  17. *
  18. * @param {String} Id of the new databinding template
  19. * @param {String} <markup> of the new databinding template
  20. */
  21. var create = function(id, markup) {
  22. _templates[id] = markup;
  23. };
  24. /**
  25. * Returns the existence of a certain Id databinding template
  26. *
  27. * @method exists
  28. *
  29. * @param {String} Id of the databinding template
  30. * @return {Boolean} true if exists, false if not.
  31. */
  32. var exists = function(id) {
  33. return (_templates[id]) ? true : false;
  34. };
  35. /**
  36. * Returns the instance of a certain Id databinding template
  37. *
  38. * @method get
  39. *
  40. * @param {String} Id of the databinding template
  41. * @return {String} Markup of template
  42. */
  43. var get = function(id) {
  44. return _templates[id];
  45. };
  46. return {
  47. create: create,
  48. exists: exists,
  49. get: get
  50. };
  51. })();