case.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. function pug_escape(e) {
  2. var a = "" + e, t = pug_match_html.exec(a);
  3. if (!t) return e;
  4. var r, c, n, s = "";
  5. for (r = t.index, c = 0; r < a.length; r++) {
  6. switch (a.charCodeAt(r)) {
  7. case 34:
  8. n = "&quot;";
  9. break;
  10. case 38:
  11. n = "&amp;";
  12. break;
  13. case 60:
  14. n = "&lt;";
  15. break;
  16. case 62:
  17. n = "&gt;";
  18. break;
  19. default:
  20. continue;
  21. }
  22. c !== r && (s += a.substring(c, r)), c = r + 1, s += n;
  23. }
  24. return c !== r ? s + a.substring(c, r) : s;
  25. }
  26. var pug_match_html = /["&<>]/;
  27. function template(locals) {
  28. var pug_html = "", pug_mixins = {}, pug_interp;
  29. pug_html = pug_html + "<html><body>";
  30. var friends = 1;
  31. switch (friends) {
  32. case 0:
  33. pug_html = pug_html + "<p>you have no friends</p>";
  34. break;
  35. case 1:
  36. pug_html = pug_html + "<p>you have a friend</p>";
  37. break;
  38. default:
  39. pug_html = pug_html + "<p>you have " + pug_escape(null == (pug_interp = friends) ? "" : pug_interp) + " friends</p>";
  40. break;
  41. }
  42. var friends = 0;
  43. switch (friends) {
  44. case 0:
  45. case 1:
  46. pug_html = pug_html + "<p>you have very few friends</p>";
  47. break;
  48. default:
  49. pug_html = pug_html + "<p>you have " + pug_escape(null == (pug_interp = friends) ? "" : pug_interp) + " friends</p>";
  50. break;
  51. }
  52. var friend = "Tim:G";
  53. switch (friend) {
  54. case "Tim:G":
  55. pug_html = pug_html + "<p>Friend is a string</p>";
  56. break;
  57. case {
  58. tim: "g"
  59. }:
  60. pug_html = pug_html + "<p>Friend is an object</p>";
  61. break;
  62. }
  63. pug_html = pug_html + "</body></html>";
  64. return pug_html;
  65. }