{"id":23906901,"url":"https://github.com/thkwag/thymelab","last_synced_at":"2026-06-18T19:31:55.172Z","repository":{"id":270570548,"uuid":"909941457","full_name":"thkwag/thymelab","owner":"thkwag","description":"ThymeLab - Thymeleaf Templates, Instantly Previewed","archived":false,"fork":false,"pushed_at":"2025-01-01T12:26:31.000Z","size":6034,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T14:16:05.419Z","etag":null,"topics":["thymelab","thymeleaf","thymeleaf-java","thymeleaf-layout","thymeleaf-spring","thymeleaf-template-engine"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thkwag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-30T05:40:59.000Z","updated_at":"2025-01-01T12:26:34.000Z","dependencies_parsed_at":"2025-01-01T13:34:55.584Z","dependency_job_id":null,"html_url":"https://github.com/thkwag/thymelab","commit_stats":null,"previous_names":["thkwag/thymelab"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/thkwag/thymelab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkwag%2Fthymelab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkwag%2Fthymelab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkwag%2Fthymelab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkwag%2Fthymelab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thkwag","download_url":"https://codeload.github.com/thkwag/thymelab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkwag%2Fthymelab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34505419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["thymelab","thymeleaf","thymeleaf-java","thymeleaf-layout","thymeleaf-spring","thymeleaf-template-engine"],"created_at":"2025-01-05T02:15:18.530Z","updated_at":"2026-06-18T19:31:55.153Z","avatar_url":"https://github.com/thkwag.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThymeLab Processor\n\nThymeLab Processor is a lightweight Spring Boot application designed to help designers and developers create and test Thymeleaf templates without setting up a complex backend system. It provides real-time hot reload capabilities, making the template development process faster and more efficient.\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"docs/images/thymelab-processor.png\" alt=\"ThymeLab Preview\"\u003e\n\u003c/p\u003e\n\n\u003e 🔗 **Related Tools**\n\u003e - [ThymeLab Launcher](https://github.com/thkwag/thymelab-launcher) - GUI application for managing ThymeLab Processor\n\u003e - [ThymeLab for VS Code](https://github.com/thkwag/thymelab-vscode) - VS Code extension for integrated development\n\n## Overview\n\nThis tool is built with Spring Boot, focusing on simplicity and ease of use. It includes only the essential features needed for Thymeleaf template development:\n- Thymeleaf template engine integration\n- Hot reload functionality\n- JSON-based data binding\n- Static resource serving\n- Basic security settings\n\n## Running the Processor\n\nYou can run ThymeLab Processor in several ways:\n\n1. **Direct Execution**:\n   ```bash\n   java -jar thymelab-processor-{version}.jar \\\n       -Dserver.port=8080 \\\n       -Dlogging.level.com.github.thkwag.thymelab=INFO \\\n       -Dwatch.directory.templates=/path/to/templates \\\n       -Dwatch.directory.thymeleaf-data=/path/to/thymelab/data \\\n       -Dwatch.directory.static=/path/to/static\n   ```\n   \n   **Configuration Options**:\n   - Server settings:\n     - `-Dserver.port=8080`: Server port number\n   - Log level:\n     - `-Dlogging.level.com.github.thkwag.thymelab=INFO`: Log level (ERROR, WARN, INFO, DEBUG, TRACE)\n   - Directory paths:\n     - `-Dwatch.directory.templates`: Template files directory\n     - `-Dwatch.directory.thymeleaf-data`: JSON data files directory\n     - `-Dwatch.directory.static`: Static resources directory\n   \n   If directory paths are not specified, the following classpath defaults will be used:\n   - Templates: `classpath:/default/templates/`\n   - Data: `classpath:/default/thymelab/data/`\n   - Static: `classpath:/default/static/`\n\n2. **Using ThymeLab Launcher**:\n   - Download [ThymeLab Launcher](https://github.com/thkwag/thymelab-launcher)\n   - GUI application for easy processor management\n   - Provides configuration UI and server controls\n\n3. **VS Code Extension**:\n   - Install [ThymeLab for VS Code](https://github.com/thkwag/thymelab-vscode)\n   - Integrated development environment\n   - Preview templates directly in VS Code\n   - Server control through VS Code interface\n\n## Key Features\n\n- **No Backend Required**: Create and test Thymeleaf templates without implementing a backend system\n- **Real-time Hot Reload**: Instantly see changes in templates, JSON data, and static resources\n- **Simple JSON Data Management**: Manage template variables using simple JSON files\n- **Layout System Support**: Create reusable layouts and fragments\n- **Static Resource Serving**: Serve and test static resources (CSS, JavaScript, images)\n- **Designer-Friendly**: Focus on template design without worrying about backend implementation\n- **Request Information Access**: Access request information in templates using the `req` variable\n\n## Benefits\n\n- **Rapid Development**: See changes instantly without server restarts\n- **Easy Collaboration**: Designers can work on templates independently\n- **Simple Setup**: Start creating templates with minimal configuration\n- **Flexible Data Management**: Modify template variables through JSON files\n- **Production-Ready Templates**: Templates created with ThymeLab can be directly used in production Spring applications\n\n## Project Structure\n\n```\nsrc/\n  └── main/\n      ├── java/\n      │   └── com/github/thkwag/thymelab/processor/\n      │       ├── config/         # Spring configurations\n      │       ├── controller/     # Web controllers\n      │       ├── hotreload/      # Hot reload implementation\n      │       ├── interceptor/    # Web interceptors\n      │       ├── service/        # Business logic services\n      │       └── ThymeLabProcessorApplication.java\n      └── resources/\n          └── default/            # Default resources\n              ├── thymelab/data/  # Default JSON data files\n              ├── static/         # Default static resources\n              └── templates/      # Default Thymeleaf templates\n```\n\n## Template Examples\n\n### Layout Template\n`templates/layout/default.html`\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml xmlns:th=\"http://www.thymeleaf.org\"\n      xmlns:layout=\"http://www.ultraq.net.nz/thymeleaf/layout\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle th:text=\"${pageTitle}\"\u003eTitle\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" th:href=\"@{/css/style.css}\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cheader th:replace=\"~{fragments/header :: header}\"\u003e\u003c/header\u003e\n    \u003cmain layout:fragment=\"content\"\u003e\u003c/main\u003e\n    \u003cfooter th:replace=\"~{fragments/footer :: footer}\"\u003e\u003c/footer\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Fragment Template\n`templates/fragments/header.html`\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml xmlns:th=\"http://www.thymeleaf.org\"\u003e\n\u003cheader th:fragment=\"header\"\u003e\n    \u003cnav\u003e\n        \u003cdiv class=\"logo\" th:text=\"${siteName}\"\u003eThymeLab\u003c/div\u003e\n        \u003cul class=\"nav-links\"\u003e\n            \u003cli th:each=\"item : ${menuItems}\" th:classappend=\"${req.requestURI == item.url ? 'active' : ''}\"\u003e\n                \u003ca th:href=\"@{${item.url}}\" th:text=\"${item.name}\"\u003eMenu Item\u003c/a\u003e\n            \u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/nav\u003e\n\u003c/header\u003e\n\u003c/html\u003e\n```\n\n### Page Template\n`templates/pages/about.html`\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml xmlns:th=\"http://www.thymeleaf.org\"\n      xmlns:layout=\"http://www.ultraq.net.nz/thymeleaf/layout\"\n      layout:decorate=\"~{layout/default}\"\u003e\n\u003chead\u003e\n    \u003ctitle th:text=\"${pageTitle}\"\u003eAbout\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cmain layout:fragment=\"content\"\u003e\n        \u003cdiv class=\"about-section\"\u003e\n            \u003ch1 th:text=\"${title}\"\u003eAbout ThymeLab\u003c/h1\u003e\n            \u003cp th:text=\"${description}\" class=\"about-description\"\u003eDescription\u003c/p\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"features\"\u003e\n            \u003cdiv th:each=\"feature : ${features}\" class=\"feature-card\"\u003e\n                \u003ch3 th:text=\"${feature.title}\"\u003eFeature Title\u003c/h3\u003e\n                \u003cp th:text=\"${feature.description}\"\u003eFeature Description\u003c/p\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/main\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Global Data\n`thymelab/data/global.json`\n```json\n{\n  \"siteName\": \"ThymeLab\",\n  \"menuItems\": [\n    {\n      \"name\": \"Home\",\n      \"url\": \"/\"\n    },\n    {\n      \"name\": \"About\",\n      \"url\": \"/pages/about.html\"\n    }\n  ]\n}\n```\n\n### Page Data\n`thymelab/data/pages/about.json`\n```json\n{\n  \"pageTitle\": \"About - ThymeLab\",\n  \"title\": \"About ThymeLab\",\n  \"description\": \"A development tool designed to streamline your Thymeleaf template development process.\",\n  \"features\": [\n    {\n      \"title\": \"Template Preview\",\n      \"description\": \"Real-time preview of Thymeleaf templates with dynamic data binding and hot reload.\"\n    },\n    {\n      \"title\": \"Project Structure\",\n      \"description\": \"Organized project structure with separate directories for templates, fragments, and static resources.\"\n    },\n    {\n      \"title\": \"Data Binding\",\n      \"description\": \"Flexible data binding system using JSON files for both global and page-specific template variables.\"\n    },\n    {\n      \"title\": \"Easy Installation\",\n      \"description\": \"Simple setup process with the ThymeLab Launcher, no complex configuration required.\"\n    }\n  ]\n}\n```\n\nThese examples demonstrate:\n- Layout template with title pattern and common structure\n- Reusable header fragment with dynamic navigation\n- Page template using layout and displaying dynamic content\n- Global JSON data for site-wide variables\n- Page-specific JSON data for individual page content\n\n\n## Request Information Access\nSince Thymeleaf 3.1, direct access to `#request`, `#session`, `#servletContext`, and `#response` objects has been restricted for security reasons ([see Migration Guide](https://www.thymeleaf.org/doc/articles/thymeleaf31whatsnew.html#expression-objects)).\n\nThymeLab provides a `req` variable through `GlobalControllerAdvice` to address this limitation and provide access to request information in templates. This feature is implemented in the `GlobalControllerAdvice` class:\n\n```java\n@ControllerAdvice\npublic class GlobalControllerAdvice {\n    \n    @ModelAttribute(\"req\")\n    public Map\u003cString, Object\u003e getRequestInfo(HttpServletRequest request) {\n        Map\u003cString, Object\u003e requestInfo = new HashMap\u003c\u003e();\n        requestInfo.put(\"requestURI\", request.getRequestURI());\n        requestInfo.put(\"requestURL\", request.getRequestURL().toString());\n        // ... other request properties\n        return requestInfo;\n    }\n}\n```\n\n### Using the req Variable\nYou can access HttpServletRequest information in templates using the `req` variable:\n\n```html\n\u003c!-- Get current URI --\u003e\n\u003cdiv th:text=\"${req.requestURI}\"\u003e\u003c/div\u003e\n\n\u003c!-- Highlight active menu item --\u003e\n\u003cli th:classappend=\"${req.requestURI == item.url ? 'active' : ''}\"\u003e\n\n\u003c!-- Get server information --\u003e\n\u003cdiv th:text=\"${req.serverName}\"\u003e\u003c/div\u003e\n```\n\n### Available req Properties\n- `req.requestURI`: Current request URI\n- `req.requestURL`: Complete URL (including protocol, host, and port)\n- `req.method`: HTTP method (GET, POST, etc.)\n- `req.protocol`: Protocol information\n- `req.scheme`: URL scheme (http, https)\n- `req.serverName`: Server name\n- `req.serverPort`: Server port\n- `req.contextPath`: Context path\n- `req.servletPath`: Servlet path\n- `req.pathInfo`: Additional path information\n- `req.queryString`: Query string\n- `req.remoteAddr`: Client IP address\n- `req.remoteHost`: Client host\n- `req.remotePort`: Client port\n- `req.localAddr`: Local IP address\n- `req.localName`: Local host name\n- `req.localPort`: Local port\n\n\n## Hot Reload\n\nHot Reload feature automatically detects changes in:\n- Template files (.html)\n- JSON data files\n- Static resources (CSS, JavaScript, images, etc.)\n\nChanges are instantly reflected in the browser without manual refresh, making the development process faster and more efficient.\n\n## Development Tips\n\n- Use the layout system to maintain consistent page structure\n- Create reusable fragments for common components\n- Organize JSON data files by feature or page\n- Utilize global.json for site-wide variables\n- Take advantage of hot reload for rapid iterations\n\n## Build and Run\n\n```bash\n# Build\n./gradlew :processor:build\n\n# Run\n./gradlew :processor:bootRun\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthkwag%2Fthymelab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthkwag%2Fthymelab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthkwag%2Fthymelab/lists"}