Skip to content

Feature request: Support rendering of partial thymeleaf fragments #66

Description

@v79

In Spring/Thymeleaf, it is possible for a controller to ask Thymeleaf to render part of a page declared as a th:fragment, e.g.:

@RequestMapping(value = "/guests", method = RequestMethod.GET)
public String showGuestList(Model model) {
    model.addAttribute("guests", hotelService.getGuestsList());
    
    return "results :: resultsList";
}

Where resultsList is defined inside a bigger Thymeleaf template as <div th:fragment="resultsList" th:unless="${#lists.isEmpty(guests)}" class="results-block">...</div>.

(As described here and elsewhere).

What would it take add the same functionality in spark? I'm willing to try it myself but don't know where to start.

When writing AJAX-heavy web pages I'm having to move all my th:fragments into separate HTML files, which breaks one of the benefits of using Thymeleaf and is a lot of effort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions