Simple image host.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

includeHtml.js 676B

1234567891011121314151617181920212223242526272829303132
  1. var fs = require("fs");
  2. var minify = require("./minify");
  3. var globalRegex = /{{([^}]+)#([^}]+)}}/g;
  4. var localRegex = /{{([^}]+)#([^}]+)}}/;
  5. module.exports = function load(path, conf) {
  6. var html = fs.readFileSync(path, "utf8");
  7. var placeholders = html.match(globalRegex);
  8. if (!placeholders)
  9. return minify.html(html);
  10. placeholders.forEach(function(p) {
  11. var parts = html.match(localRegex);
  12. var s = parts[0];
  13. var ns = parts[1];
  14. var key = parts[2];
  15. switch (ns) {
  16. case "conf":
  17. html = html.replace(s, conf[key]);
  18. break;
  19. case "template":
  20. html = html.replace(s, load("templates/"+key+".html", conf));
  21. break;
  22. }
  23. });
  24. return minify.html(html);
  25. }