Grace Plugin for using Grace/Grails app with Inertia.js.
Add dependency to the build.gradle
,
repositories {
mavenCentral()
}
dependencies {
implementation "org.graceframework.plugins:inertia:VERSION"
}
Inertia plugin supports controller-specific withFormat()
method,
class BookController {
def list() {
def books = Book.list()
withFormat {
inertia {
render(inertia: "Book/List", props: [bookList: books])
}
json {
render books as JSON
}
}
}
}
Also, this plugin supports extendsions for Grails Request and Response,
// You can get Inertia request headers from Grails Request
request.inertia.version == request.getHeader('X-Inertia-Version')
// Check Inertia request?
if (request.inertia as boolean) { // or use request.isInertia()
template = 'book-detail'
}
// You can set Inertia response headers in Grails
response.inertia.location = 'http://localhost:8080/book/1'
git clone https://github.com/grace-plugins/grace-inertia.git
cd grace-inertia
./gradlew publishToMavenLocal
- Grace 2022.0.0+
- Grails 3.0+
- Inertia 1.x
This plugin is available as open source under the terms of the APACHE LICENSE, VERSION 2.0