瀏覽代碼

add sha256expr handlebars helper

tags/2.0.1
Jonathan Cobb 4 年之前
父節點
當前提交
fc87156268
共有 1 個檔案被更改,包括 7 行新增0 行删除
  1. +7
    -0
      src/main/java/org/cobbzilla/util/handlebars/HandlebarsUtil.java

+ 7
- 0
src/main/java/org/cobbzilla/util/handlebars/HandlebarsUtil.java 查看文件

@@ -275,6 +275,13 @@ public class HandlebarsUtil extends AbstractTemplateLoader {
return new Handlebars.SafeString(src.toString());
});

hb.registerHelper("sha256expr", (src, options) -> {
if (empty(src)) return "";
src = apply(hb, src.toString(), (Map<String, Object>) options.context.model(), '[', ']');
src = sha256_hex(src.toString());
return new Handlebars.SafeString(src.toString());
});

hb.registerHelper("safeSql", (src, options) -> {
if (empty(src)) return "";
final String illegalChars = src.toString().replaceAll("[A-Za-z0-9=<>_\\()\\s\\.]+", "");


Loading…
取消
儲存