Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noobdevsam/jte-templates
https://github.com/noobdevsam/jte-templates
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/noobdevsam/jte-templates
- Owner: noobdevsam
- Created: 2024-10-14T08:27:56.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T04:55:13.000Z (3 months ago)
- Last Synced: 2024-11-10T13:42:30.421Z (about 2 months ago)
- Language: Java
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot & JTE Templates
## Relevant Code Examples
### JTE Template
JTE templates are located in the `src/main/jte/pages` directory. Here's a simple example of what a JTE template might look like:
```html
@param String username@template.layout.main(content = @`
Welcome, ${username}!
This is your dashboard. Here you can view your recent activity and manage your account.
`)
```This template takes a `username` parameter and renders it within the HTML. This template declares that it is using the `main` layout.
## JTE Content and Layouts
### Understanding Content in JTE
In JTE, `gg.jte.Content` is a special parameter type used to pass template code to other templates, similar to lambdas in Java. This feature is particularly useful for sharing structures between different templates and creating reusable layouts.
### Main Layout
The main layout for this project is located at `/src/main/jte/layout/main.jte`. This layout serves as the base structure for other pages in the application. Here's an example of how a main layout might look:
```jte
@import gg.jte.Content@param String title
@param Content content
${title}
${title}
${content}
© 2024 Spring Boot & JTE Templates
```
### Using Content Blocks
To use content blocks within JTE templates, you can use the shorthand syntax of `@` followed by two backticks. Here's an example of how you might use the main layout in another template:
```jte
@import dev.danvega.jte.TemplateController@param String username
@template.layout.main(
title = "Welcome",
content = @`
Welcome, ${username}!
This is a JTE template rendered by Spring Boot.
`
)
```This approach allows for clean separation of concerns, making your templates more modular and easier to maintain.