Here are the examples of the java api com.blade.mvc.view.template.JetbrickTemplateEngine.getGlobalResolver() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
11
Source : WebContext.java
with MIT License
from tfssweb
with MIT License
from tfssweb
@Override
public void processor(Blade blade) {
JetbrickTemplateEngine templateEngine = new JetbrickTemplateEngine();
List<String> macros = new ArrayList<>(8);
macros.add(File.separatorChar + "comm" + File.separatorChar + "macros.html");
// 扫描主题下面的所有自定义宏
String themeDir = AttachController.CLreplacedPATH + "templates" + File.separatorChar + "themes";
File[] dir = new File(themeDir).listFiles();
for (File f : dir) {
if (f.isDirectory() && Files.exists(Paths.get(f.getPath() + File.separatorChar + "macros.html"))) {
String macroName = File.separatorChar + "themes" + File.separatorChar + f.getName() + File.separatorChar + "macros.html";
macros.add(macroName);
}
}
StringBuffer sbuf = new StringBuffer();
macros.forEach(s -> sbuf.append(',').append(s));
templateEngine.addConfig("jetx.import.macros", sbuf.substring(1));
GlobalResolver resolver = templateEngine.getGlobalResolver();
resolver.registerFunctions(Commons.clreplaced);
resolver.registerFunctions(Theme.clreplaced);
resolver.registerFunctions(AdminCommons.clreplaced);
resolver.registerTags(JetTag.clreplaced);
JetGlobalContext context = templateEngine.getGlobalContext();
context.set("version", environment.get("app.version", "v1.0"));
context.set("enableCdn", environment.getBoolean("app.enableCdn", false));
blade.templateEngine(templateEngine);
TaleConst.ENABLED_CDN = environment.getBoolean("app.enableCdn", false);
TaleConst.MAX_FILE_SIZE = environment.getInt("app.max-file-size", 20480);
TaleConst.AES_SALT = environment.get("app.salt", "012c456789abcdef");
TaleConst.OPTIONS.addAll(optionsService.getOptions());
String ips = TaleConst.OPTIONS.get(Types.BLOCK_IPS, "");
if (StringKit.isNotBlank(ips)) {
TaleConst.BLOCK_IPS.addAll(Arrays.asList(ips.split(",")));
}
if (Files.exists(Paths.get(AttachController.CLreplacedPATH + "install.lock"))) {
TaleConst.INSTALLED = Boolean.TRUE;
}
BaseController.THEME = "themes/" + Commons.site_option("site_theme");
TaleConst.BCONF = environment;
}
11
Source : Bootstrap.java
with MIT License
from biezhi
with MIT License
from biezhi
@Override
public void load(Blade blade) {
// 使用 gson 作为 JSON 支持
JsonKit.jsonSupprt(new GsonSupport());
DBUtils.importSql(blade.devMode());
Anima.open(DBUtils.DB_SRC);
JetbrickTemplateEngine templateEngine = new JetbrickTemplateEngine();
templateEngine.getGlobalResolver().registerFunctions(TemplateExt.clreplaced);
blade.templateEngine(templateEngine);
// 初始化主题、全局变量信息
Option theme = select().from(Option.clreplaced).where(Option::getKey, CURRENT_THEME).one();
if (null != theme) {
IndexController.THEME_NAME = theme.getValue();
}
List<Option> all = select().from(Option.clreplaced).all();
if (null != all) {
GLOBAL_CONFIG = all.stream().collect(toMap(Option::getKey, (Option::getValue)));
}
payApi = PayApi.getPayApi(GLOBAL_CONFIG.get(SAFE_PLATFORM));
}