freemarker.core.Environment.getCurrentDirectiveCallPlace()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中freemarker.core.Environment.getCurrentDirectiveCallPlace()方法的一些代码示例,展示了Environment.getCurrentDirectiveCallPlace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getCurrentDirectiveCallPlace()方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:getCurrentDirectiveCallPlace

Environment.getCurrentDirectiveCallPlace介绍

[英]Gets the currently executing custom directive's call place information, or null if there's no executing custom directive. This currently only works for calls made from templates with the syntax. This should only be called from the TemplateDirectiveModel that was invoked with , otherwise its return value is not defined by this API (it's usually null).
[中]获取当前正在执行的custom指令的调用位置信息,如果没有正在执行的自定义指令,则为null。这目前仅适用于使用语法的模板进行的调用。只能从调用的TemplateDirectiveModel调用它,否则它的返回值不由该API定义(通常为null)。

代码示例

代码示例来源:origin: sanluan/PublicCMS

  1. @Override
  2. public void execute(Environment environment, @SuppressWarnings("rawtypes") Map parameters, TemplateModel[] templateModel,
  3. TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
  4. if (null != templateDirectiveBody) {
  5. TemplateModel model = environment.getVariable(TemplateCacheComponent.CACHE_VAR);
  6. if (null != model && model instanceof TemplateBooleanModel) {
  7. try {
  8. DirectiveCallPlace directiveCallPlace = environment.getCurrentDirectiveCallPlace();
  9. if (null != directiveCallPlace) {
  10. environment.getOut().append(directiveCallPlace.toString());
  11. }
  12. } catch (Exception e) {
  13. environment.getOut().append(e.getMessage());
  14. }
  15. } else {
  16. templateDirectiveBody.render(environment.getOut());
  17. }
  18. }
  19. }
  20. }

代码示例来源:origin: sanluan/PublicCMS

  1. @Override
  2. public void execute(Environment environment, @SuppressWarnings("rawtypes") Map parameters, TemplateModel[] templateModel,
  3. TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
  4. if (null != templateDirectiveBody) {
  5. TemplateModel model = environment.getVariable(TemplateCacheComponent.CACHE_VAR);
  6. if (null != model && model instanceof TemplateBooleanModel) {
  7. try {
  8. DirectiveCallPlace directiveCallPlace = environment.getCurrentDirectiveCallPlace();
  9. if (null != directiveCallPlace) {
  10. environment.getOut().append(directiveCallPlace.toString());
  11. }
  12. } catch (Exception e) {
  13. environment.getOut().append(e.getMessage());
  14. }
  15. } else {
  16. templateDirectiveBody.render(environment.getOut());
  17. }
  18. }
  19. }
  20. }

相关文章

Environment类方法