当前位置: 首页>>代码示例>>Java>>正文


Java TemplateEngine类代码示例

本文整理汇总了Java中io.vertx.ext.web.templ.TemplateEngine的典型用法代码示例。如果您正苦于以下问题:Java TemplateEngine类的具体用法?Java TemplateEngine怎么用?Java TemplateEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TemplateEngine类属于io.vertx.ext.web.templ包,在下文中一共展示了TemplateEngine类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
@Override
public void handle(RoutingContext context) {
  String tplName = normalize(config.getTplDir()) + ViewResolver.getViewName(context);
  TemplateEngine engine = fromViewName(tplName);
  if (engine == null) {
    LOG.error("No template handler found for " + tplName);
    context.fail(500);
    return;
  }
  engine.render(context, tplName, res -> {
    if (res.succeeded()) {
      context.response().putHeader(CONTENT_TYPE, "text/html").end(res.result());
    } else {
      context.fail(res.cause());
    }
  });
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:18,代码来源:TemplateEngineManager.java

示例2: testDefaultIndex

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
@Test
public void testDefaultIndex() {
  TemplateEngine templateEngine = mock(TemplateEngine.class);
  RoutingContext routingContext = mock(RoutingContext.class);
  when(routingContext.normalisedPath()).thenReturn("/");
  Route currentRoute = mock(Route.class);
  when(currentRoute.getPath()).thenReturn("/");
  when(routingContext.currentRoute()).thenReturn(currentRoute);

  TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
  templateHandler.handle(routingContext);

  verify(templateEngine).render(any(), eq("templates"), eq("/index"), any());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:15,代码来源:TemplateHandlerImplTest.java

示例3: testSetIndex

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
@Test
public void testSetIndex() {
  TemplateEngine templateEngine = mock(TemplateEngine.class);
  RoutingContext routingContext = mock(RoutingContext.class);
  when(routingContext.normalisedPath()).thenReturn("/");
  Route currentRoute = mock(Route.class);
  when(currentRoute.getPath()).thenReturn("/");
  when(routingContext.currentRoute()).thenReturn(currentRoute);

  TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
  templateHandler.setIndexTemplate("home");
  templateHandler.handle(routingContext);

  verify(templateEngine).render(any(), eq("templates"), eq("/home"), any());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:16,代码来源:TemplateHandlerImplTest.java

示例4: testTurnOffIndex

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
@Test
public void testTurnOffIndex() {
  TemplateEngine templateEngine = mock(TemplateEngine.class);
  RoutingContext routingContext = mock(RoutingContext.class);
  when(routingContext.normalisedPath()).thenReturn("/");
  Route currentRoute = mock(Route.class);
  when(currentRoute.getPath()).thenReturn("/");
  when(routingContext.currentRoute()).thenReturn(currentRoute);

  TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
  templateHandler.setIndexTemplate(null);
  templateHandler.handle(routingContext);

  verify(templateEngine).render(any(), eq("templates"), eq("/"), any());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:16,代码来源:TemplateHandlerImplTest.java

示例5: testSimpleTemplate

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
@Test
public void testSimpleTemplate() {
  TemplateEngine templateEngine = mock(TemplateEngine.class);
  RoutingContext routingContext = mock(RoutingContext.class);
  when(routingContext.normalisedPath()).thenReturn("/about");
  Route currentRoute = mock(Route.class);
  when(currentRoute.getPath()).thenReturn("/");
  when(routingContext.currentRoute()).thenReturn(currentRoute);

  TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
  templateHandler.handle(routingContext);

  verify(templateEngine).render(any(), eq("templates"), eq("/about"), any());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:15,代码来源:TemplateHandlerImplTest.java

示例6: fromViewName

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
public TemplateEngine fromViewName(String tplName) {
  int pointIdx = tplName.lastIndexOf('.');
  String extension = tplName.substring(pointIdx + 1, tplName.length());
  return config.getTemplateEngines().get(extension);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:6,代码来源:TemplateEngineManager.java

示例7: registerTemplateEngine

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
public void registerTemplateEngine(String extension, TemplateEngine engine) {
  config.registerTemplateEngine(extension, engine);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:4,代码来源:VertxNubes.java

示例8: TemplateHandlerImpl

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
public TemplateHandlerImpl(TemplateEngine engine, String templateDirectory, String contentType) {
  this.engine = engine;
  this.templateDirectory = templateDirectory == null || templateDirectory.isEmpty() ? "." : templateDirectory;
  this.contentType = contentType;
  this.indexTemplate = DEFAULT_INDEX_TEMPLATE;
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:7,代码来源:TemplateHandlerImpl.java

示例9: example41_2

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
public void example41_2(Router router, TemplateEngine engine) {

    TemplateHandler handler = TemplateHandler.create(engine);

    router.get("/dynamic").handler(routingContext -> {

      routingContext.put("request_path", routingContext.request().path());
      routingContext.put("session_data", routingContext.session().data());

      routingContext.next();
    });

    router.get("/dynamic/").handler(handler);

  }
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:16,代码来源:WebExamples.java

示例10: getThymeleafTemplateEngine

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
/**
 * Get a reference to the internal Thymeleaf TemplateEngine object so it
 * can be configured.
 *
 * @return a reference to the internal Thymeleaf TemplateEngine instance.
 */
org.thymeleaf.TemplateEngine getThymeleafTemplateEngine();
 
开发者ID:quebic-source,项目名称:puppy-io,代码行数:8,代码来源:CustomThymeleafTemplateEngine.java

示例11: create

import io.vertx.ext.web.templ.TemplateEngine; //导入依赖的package包/类
/**
 * Create a handler
 *
 * @param engine  the template engine
 * @return the handler
 */
static TemplateHandler create(TemplateEngine engine) {
  return new TemplateHandlerImpl(engine, DEFAULT_TEMPLATE_DIRECTORY, DEFAULT_CONTENT_TYPE);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:10,代码来源:TemplateHandler.java


注:本文中的io.vertx.ext.web.templ.TemplateEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。