{"repo":"tschuehly/spring-view-component","free":true,"listed":false,"github":"https://github.com/tschuehly/spring-view-component","clone":"git clone https://github.com/tschuehly/spring-view-component.git","description":"Server-side UI components with spring boot","language":"Kotlin","stars":236,"topics":["kotlin","spring","spring-boot","ssr","thymeleaf","htmx","jte"],"license":"MIT","category":"ui-components","readme_excerpt":"Spring ViewComponent allows you to create typesafe, reusable & encapsulated server-rendered UI components. Table of Contents - What’s a ViewComponent? - Render a ViewComponent - Nesting ViewComponents: - Local Development Configuration - Production Configuration - Installation - Technical Implementation What’s a ViewComponent? ViewComponents consolidate the logic needed for a template into a single class, resulting in a cohesive object that is easy to understand. (Source: ViewComponent for Rails) A Spring ViewComponent is a Spring Bean that defines the context for our Template: Java We define the context by creating a record that implements the ViewContext interface Next, we add the @ViewComponent annotation to a class and define a method that returns the SimpleView record. Kotlin A ViewComponent always needs a corresponding HTML Template. We define the Template in the SimpleViewComponent.[html/jte/kte] In the same package as our ViewComponent class. We can use Thymeleaf or JTE or KTE Render a ViewComponent We can then call the render method in our controller to render the template. Java Kotlin Examples If you want to get started right away you can find examples for all possible language combinations here: Examples Nesting ViewComponents: We can nest components by passing a ViewContext as property of our record, if we also have it as parameter of our render method we can easily create layouts: Java Kotlin Thymeleaf In Thymeleaf we render the passed ViewComponent with the view","default_branch":null,"files":null,"tree":[],"storefront":"/r/tschuehly","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/tschuehly/spring-view-component/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}