ro.pippo.core.Application.getTemplateEngine()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(84)

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

Application.getTemplateEngine介绍

暂无

代码示例

代码示例来源:origin: pippo-java/pippo

public Response(HttpServletResponse httpServletResponse, Application application) {
  this.httpServletResponse = httpServletResponse;
  this.contentTypeEngines = application.getContentTypeEngines();
  this.templateEngine = application.getTemplateEngine();
  this.httpServletResponse.setCharacterEncoding(StandardCharsets.UTF_8.toString());
  this.contextPath = application.getRouter().getContextPath();
  this.applicationPath = StringUtils.removeEnd(application.getRouter().getApplicationPath(), "/");
  this.mimeTypes = application.getMimeTypes();
  this.status = 0;
}

代码示例来源:origin: pippo-java/pippo

protected void renderHtml(int statusCode, RouteContext routeContext) {
  TemplateEngine engine = application.getTemplateEngine();
  if (engine == null) {
    renderDirectly(statusCode, routeContext);
  } else {
    String template = getTemplateForStatusCode(statusCode);
    if (template == null) {
      log.debug("There is no {} template for status code '{}'", engine.getClass().getSimpleName(), statusCode);
      renderDirectly(statusCode, routeContext);
    } else {
      try {
        Error error = prepareError(statusCode, routeContext);
        Map<String, Object> bindings = error.asMap();
        bindings.putAll(prepareTemplateBindings(statusCode, routeContext));
        routeContext.setLocals(bindings);
        routeContext.render(template);
      } catch (Exception e) {
        log.error("Unexpected error rendering '{}' template", template, e);
        renderDirectly(statusCode, routeContext);
      }
    }
  }
}

代码示例来源:origin: com.gitblit.fathom/fathom-rest

private void logEngines() {
  if (!settings.getBoolean(SETTING_ENGINES_LOG, true)) {
    return;
  }
  TemplateEngine templateEngine = application.getTemplateEngine();
  ContentTypeEngines engines = application.getContentTypeEngines();
  List<String> contentTypes = new ArrayList<>(engines.getContentTypes());
  Collections.sort(contentTypes);
  int maxContentTypeLen = 0;
  int maxTemplateEngineLen = templateEngine == null ? 0 : templateEngine.getClass().getName().length();
  for (String contentType : contentTypes) {
    ContentTypeEngine engine = engines.getContentTypeEngine(contentType);
    maxContentTypeLen = Math.max(maxContentTypeLen, contentType.length());
    maxTemplateEngineLen = Math.max(maxTemplateEngineLen, engine.getClass().getName().length());
  }
  if (templateEngine != null) {
    log.info("{}  =>  {}",
        Strings.padEnd("templates", maxContentTypeLen, ' '),
        templateEngine.getClass().getName());
  }
  for (String contentType : contentTypes) {
    ContentTypeEngine engine = engines.getContentTypeEngine(contentType);
    log.info("{}  =>  {}",
        Strings.padEnd(contentType, maxContentTypeLen, ' '),
        engine.getClass().getName());
  }
}

代码示例来源:origin: gitblit/fathom

private void logEngines() {
  if (!settings.getBoolean(SETTING_ENGINES_LOG, true)) {
    return;
  }
  TemplateEngine templateEngine = application.getTemplateEngine();
  ContentTypeEngines engines = application.getContentTypeEngines();
  List<String> contentTypes = new ArrayList<>(engines.getContentTypes());
  Collections.sort(contentTypes);
  int maxContentTypeLen = 0;
  int maxTemplateEngineLen = templateEngine == null ? 0 : templateEngine.getClass().getName().length();
  for (String contentType : contentTypes) {
    ContentTypeEngine engine = engines.getContentTypeEngine(contentType);
    maxContentTypeLen = Math.max(maxContentTypeLen, contentType.length());
    maxTemplateEngineLen = Math.max(maxTemplateEngineLen, engine.getClass().getName().length());
  }
  if (templateEngine != null) {
    log.info("{}  =>  {}",
        Strings.padEnd("templates", maxContentTypeLen, ' '),
        templateEngine.getClass().getName());
  }
  for (String contentType : contentTypes) {
    ContentTypeEngine engine = engines.getContentTypeEngine(contentType);
    log.info("{}  =>  {}",
        Strings.padEnd(contentType, maxContentTypeLen, ' '),
        engine.getClass().getName());
  }
}

代码示例来源:origin: com.gitblit.fathom/fathom-rest

@Override
protected void setup() {
  String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim();
  serve(basePath + "/*").with(RestServlet.class);
  final PippoSettings pippoSettings = getPippoSettings(getSettings());
  final Application application = new Application(pippoSettings);
  // must set context path before starting application
  application.getRouter().setContextPath(getSettings().getContextPath());
  // must set application path before starting application
  String contextPath = application.getRouter().getContextPath();
  String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/");
  application.getRouter().setApplicationPath(applicationPath);
  // start the application which sets up all initializers
  application.init();
  bind(Application.class).toInstance(application);
  bind(Router.class).toInstance(application.getRouter());
  bind(Messages.class).toInstance(application.getMessages());
  bind(Languages.class).toInstance(application.getLanguages());
  bind(MimeTypes.class).toInstance(application.getMimeTypes());
  bind(ErrorHandler.class).toInstance(application.getErrorHandler());
  bind(TemplateEngine.class).toInstance(application.getTemplateEngine());
  bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit());
  bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines());
  bind(RestService.class);
}

代码示例来源:origin: gitblit/fathom

@Override
protected void setup() {
  String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim();
  serve(basePath + "/*").with(RestServlet.class);
  final PippoSettings pippoSettings = getPippoSettings(getSettings());
  final Application application = new Application(pippoSettings);
  // must set context path before starting application
  application.getRouter().setContextPath(getSettings().getContextPath());
  // must set application path before starting application
  String contextPath = application.getRouter().getContextPath();
  String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/");
  application.getRouter().setApplicationPath(applicationPath);
  // start the application which sets up all initializers
  application.init();
  bind(Application.class).toInstance(application);
  bind(Router.class).toInstance(application.getRouter());
  bind(Messages.class).toInstance(application.getMessages());
  bind(Languages.class).toInstance(application.getLanguages());
  bind(MimeTypes.class).toInstance(application.getMimeTypes());
  bind(ErrorHandler.class).toInstance(application.getErrorHandler());
  bind(TemplateEngine.class).toInstance(application.getTemplateEngine());
  bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit());
  bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines());
  bind(RestService.class);
}

相关文章