Trang thông tin tổng hợp
Trang thông tin tổng hợp
  • người nổi tiếng
  • Thơ Văn Học
  • chính tả
  • Hình ảnh đẹp
người nổi tiếng Thơ Văn Học chính tả Hình ảnh đẹp
  1. Trang chủ
  2. ảnh tổng hợp
Mục Lục

Jte: Java Template Engine¶

avatar
kenvin
06:24 21/11/2025

Mục Lục

jtejte (Java Template Engine) is a secure and lightweight template engine for Java and Kotlin. jte is designed to introduce as few new keywords as possible and builds upon existing language features, making it straightforward to reason about what a template does. The IntelliJ plugin offers full completion and refactoring support for Java parts and jte keywords.

Build Status Coverage Status

Features¶

Getting started¶

jte is available on Maven Central:

No further dependencies are required! Check out the syntax documentation and have fun with jte.

IntelliJ Plugin¶

jte gives you the same productive, typesafe experience you're used to from writing Java or Kotlin. Here is a quick demo of the IntelliJ jte plugin:

5 minutes example¶

Here is a small jte template example.jte (or example.kte if using Kotlin):

So what is going on here?

  • @import directly translates to Java/Kotlin imports, in this case, so that org.example.Page is known to the template.
  • @param Page page is the parameter that needs to be passed to this template.
  • @if/@endif is an if-block. The stuff inside the parentheses (page.getDescription() != null) is plain Java code.
  • ${} writes to the underlying template output, as known from various other template engines.

To render this template, an instance of gg.jte.TemplateEngine is required. Typically, you create it once per application (it is safe to share the engine between threads):

With the gg.jte.TemplateEngine ready, templates are rendered like this:

If you had more than one page like example.jte, you would have to duplicate a lot of shared template code. Let's extract the shared code into a reusable template.

Let's move stuff from our example page to layout.jte:

The @param Content content is a content block that callers of the template can provide. ${content} renders this content block. Let's refactor example.jte to use the new template:

The shorthand to create content blocks within jte templates is an @ followed by two backticks. For advanced stuff, you can even create Java methods that return custom gg.jte.Content implementation and call it from your template code!

Check out the syntax documentation for a more comprehensive introduction.

Performance¶

By 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 concurrency¶

This is the same benchmark as above, but the amount of threads was set to @Threads(16), to fully utilize all cores. jte has pretty much zero serialization bottlenecks and runs very concurrent on servers with many CPU cores:

Framework integration¶

  • Javalin
  • Eclipse Vert.x
  • Spring Boot
  • Spring Web MVC
  • Ktor
  • Micronaut
  • Quarkus
  • Severell
  • http4k

Websites rendered with jte¶

  • Mazebert TD (game website)
  • Javalin website example with login and multiple languages
  • FlowCrypt Admin Panel
0 Thích
Chia sẻ
  • Chia sẻ Facebook
  • Chia sẻ Twitter
  • Chia sẻ Zalo
  • Chia sẻ Pinterest
In
  • Điều khoản sử dụng
  • Chính sách bảo mật
  • Cookies
  • RSS
  • Điều khoản sử dụng
  • Chính sách bảo mật
  • Cookies
  • RSS

Cdspvinhlong

Cdspvinhlong Website chia sẻ video, tài liệu, chương trình đào tạo và các hoạt động chuyên môn về sư phạm dành cho giáo viên, sinh viên và những người yêu giáo dục tại Vĩnh Long. Nền tảng hỗ trợ cập nhật kiến thức, kết nối cộng đồng và nâng cao kỹ năng giảng dạy.

© 2026 - Cdspvinhlong

Kết nối với Cdspvinhlong

Trang thông tin tổng hợp
  • Trang chủ
  • người nổi tiếng
  • Thơ Văn Học
  • chính tả
  • Hình ảnh đẹp
Đăng ký / Đăng nhập
Quên mật khẩu?
Chưa có tài khoản? Đăng ký