Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/noobdevsam/jte-templates


https://github.com/noobdevsam/jte-templates

Last synced: 30 days ago
JSON representation

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.