迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):casid/jte开源软件地址(OpenSource Url):https://github.com/casid/jte开源编程语言(OpenSource Language):Java 98.5%开源软件介绍(OpenSource Introduction):
Features
TLDRjte gives you the same productive, type safe experience you're used to from writing Java or Kotlin. This is IntelliJ with the jte plugin installed: 5 minutes exampleHere is a small jte template @import org.example.Page
@param Page page
<head>
@if(page.getDescription() != null)
<meta name="description" content="${page.getDescription()}">
@endif
<title>${page.getTitle()}</title>
</head>
<body>
<h1>${page.getTitle()}</h1>
<p>Welcome to my example page!</p>
</body> So what is going on here?
To render this template, an instance of CodeResolver codeResolver = new DirectoryCodeResolver(Path.of("jte")); // This is the directory where your .jte files are located.
TemplateEngine templateEngine = TemplateEngine.create(codeResolver, ContentType.Html); // Two choices: Plain or Html The content type passed to the engine determines how user output will be escaped. If you render HTML files, With the TemplateOutput output = new StringOutput();
templateEngine.render("example.jte", page, output);
System.out.println(output);
If you had more than one page like Let's move stuff from our example page to @import org.example.Page
@import gg.jte.Content
@param Page page
@param Content content
<head>
@if(page.getDescription() != null)
<meta name="description" content="${page.getDescription()}">
@endif
<title>${page.getTitle()}</title>
</head>
<body>
<h1>${page.getTitle()}</h1>
${content}
</body> The @import org.example.Page
@param Page page
@template.layout(page = page, content = @`
<p>Welcome to my example page!</p>
`) The shorthand to create content blocks within jte templates is an Check out the syntax documentation, for a more comprehensive introduction. PerformanceBy design, jte provides very fast output. This is a fork of mbosecke/template-benchmark with jte included, running on AMD Ryzen 5950x (single thread): High concurrencyThis is the same benchmark as above, but the amount of threads was set to Getting startedjte is available on Maven Central: Maven<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte</artifactId>
<version>2.1.1</version>
</dependency> Gradleimplementation group: 'gg.jte', name: 'jte', version: '2.1.1' No further dependencies required! Check out the syntax documentation and have fun with jte. Framework integrationWebsites rendered with jte
![]() |
2022-08-15
2022-08-17
2023-10-27
2022-09-23
2022-08-13
请发表评论