pug.test.js.snap 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. exports[`pug .compileClient() should support module syntax in pug.compileClient(str, options) when inlineRuntimeFunctions it false 1`] = `
  2. "var pug = require(\"pug-runtime\");
  3. function template(locals) {
  4. var pug_html = \"\",
  5. pug_mixins = {},
  6. pug_interp;
  7. var pug_debug_filename, pug_debug_line;
  8. try {
  9. var self = locals || {};
  10. pug_debug_line = 1;
  11. pug_html = pug_html + \'\\u003Cdiv class=\"bar\"\\u003E\';
  12. pug_debug_line = 1;
  13. pug_html =
  14. pug_html +
  15. pug.escape(null == (pug_interp = self.foo) ? \"\" : pug_interp) +
  16. \"\\u003C\\u002Fdiv\\u003E\";
  17. } catch (err) {
  18. pug.rethrow(err, pug_debug_filename, pug_debug_line);
  19. }
  20. return pug_html;
  21. }
  22. module.exports = template;
  23. "
  24. `;
  25. exports[`pug .compileClient() should support module syntax in pug.compileClient(str, options) when inlineRuntimeFunctions it true 1`] = `
  26. "function pug_escape(e) {
  27. var a = \"\" + e,
  28. t = pug_match_html.exec(a);
  29. if (!t) return e;
  30. var r,
  31. c,
  32. n,
  33. s = \"\";
  34. for (r = t.index, c = 0; r < a.length; r++) {
  35. switch (a.charCodeAt(r)) {
  36. case 34:
  37. n = \"&quot;\";
  38. break;
  39. case 38:
  40. n = \"&amp;\";
  41. break;
  42. case 60:
  43. n = \"&lt;\";
  44. break;
  45. case 62:
  46. n = \"&gt;\";
  47. break;
  48. default:
  49. continue;
  50. }
  51. c !== r && (s += a.substring(c, r)), (c = r + 1), (s += n);
  52. }
  53. return c !== r ? s + a.substring(c, r) : s;
  54. }
  55. var pug_match_html = /[\"&<>]/;
  56. function pug_rethrow(n, e, r, t) {
  57. if (!(n instanceof Error)) throw n;
  58. if (!((\"undefined\" == typeof window && e) || t))
  59. throw ((n.message += \" on line \" + r), n);
  60. try {
  61. t = t || require(\"fs\").readFileSync(e, \"utf8\");
  62. } catch (e) {
  63. pug_rethrow(n, null, r);
  64. }
  65. var i = 3,
  66. a = t.split(\"\\n\"),
  67. o = Math.max(r - i, 0),
  68. h = Math.min(a.length, r + i),
  69. i = a
  70. .slice(o, h)
  71. .map(function(n, e) {
  72. var t = e + o + 1;
  73. return (t == r ? \" > \" : \" \") + t + \"| \" + n;
  74. })
  75. .join(\"\\n\");
  76. throw ((n.path = e),
  77. (n.message = (e || \"Pug\") + \":\" + r + \"\\n\" + i + \"\\n\\n\" + n.message),
  78. n);
  79. }
  80. function template(locals) {
  81. var pug_html = \"\",
  82. pug_mixins = {},
  83. pug_interp;
  84. var pug_debug_filename, pug_debug_line;
  85. try {
  86. var self = locals || {};
  87. pug_debug_line = 1;
  88. pug_html = pug_html + \'\\u003Cdiv class=\"bar\"\\u003E\';
  89. pug_debug_line = 1;
  90. pug_html =
  91. pug_html +
  92. pug_escape(null == (pug_interp = self.foo) ? \"\" : pug_interp) +
  93. \"\\u003C\\u002Fdiv\\u003E\";
  94. } catch (err) {
  95. pug_rethrow(err, pug_debug_filename, pug_debug_line);
  96. }
  97. return pug_html;
  98. }
  99. module.exports = template;
  100. "
  101. `;