Le repo des sources pour le site web des JM2L
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

88 linhas
2.6 KiB

  1. /*
  2. * JavaScript Templates 2.4.1
  3. * https://github.com/blueimp/JavaScript-Templates
  4. *
  5. * Copyright 2011, Sebastian Tschan
  6. * https://blueimp.net
  7. *
  8. * Licensed under the MIT license:
  9. * http://www.opensource.org/licenses/MIT
  10. *
  11. * Inspired by John Resig's JavaScript Micro-Templating:
  12. * http://ejohn.org/blog/javascript-micro-templating/
  13. */
  14. /*jslint evil: true, regexp: true, unparam: true */
  15. /*global document, define */
  16. (function ($) {
  17. "use strict";
  18. var tmpl = function (str, data) {
  19. var f = !/[^\w\-\.:]/.test(str) ? tmpl.cache[str] = tmpl.cache[str] ||
  20. tmpl(tmpl.load(str)) :
  21. new Function(
  22. tmpl.arg + ',tmpl',
  23. "var _e=tmpl.encode" + tmpl.helper + ",_s='" +
  24. str.replace(tmpl.regexp, tmpl.func) +
  25. "';return _s;"
  26. );
  27. return data ? f(data, tmpl) : function (data) {
  28. return f(data, tmpl);
  29. };
  30. };
  31. tmpl.cache = {};
  32. tmpl.load = function (id) {
  33. return document.getElementById(id).innerHTML;
  34. };
  35. tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g;
  36. tmpl.func = function (s, p1, p2, p3, p4, p5) {
  37. if (p1) { // whitespace, quote and backspace in HTML context
  38. return {
  39. "\n": "\\n",
  40. "\r": "\\r",
  41. "\t": "\\t",
  42. " " : " "
  43. }[p1] || "\\" + p1;
  44. }
  45. if (p2) { // interpolation: {%=prop%}, or unescaped: {%#prop%}
  46. if (p2 === "=") {
  47. return "'+_e(" + p3 + ")+'";
  48. }
  49. return "'+(" + p3 + "==null?'':" + p3 + ")+'";
  50. }
  51. if (p4) { // evaluation start tag: {%
  52. return "';";
  53. }
  54. if (p5) { // evaluation end tag: %}
  55. return "_s+='";
  56. }
  57. };
  58. tmpl.encReg = /[<>&"'\x00]/g;
  59. tmpl.encMap = {
  60. "<" : "&lt;",
  61. ">" : "&gt;",
  62. "&" : "&amp;",
  63. "\"" : "&quot;",
  64. "'" : "&#39;"
  65. };
  66. tmpl.encode = function (s) {
  67. /*jshint eqnull:true */
  68. return (s == null ? "" : "" + s).replace(
  69. tmpl.encReg,
  70. function (c) {
  71. return tmpl.encMap[c] || "";
  72. }
  73. );
  74. };
  75. tmpl.arg = "o";
  76. tmpl.helper = ",print=function(s,e){_s+=e?(s==null?'':s):_e(s);}" +
  77. ",include=function(s,d){_s+=tmpl(s,d);}";
  78. if (typeof define === "function" && define.amd) {
  79. define(function () {
  80. return tmpl;
  81. });
  82. } else {
  83. $.tmpl = tmpl;
  84. }
  85. }(this));