GithubHelp home page GithubHelp logo

grails-htmx's Introduction

Announcement

In order to support both Grails and Grace, reduce maintenance costs, and focus on developing new features, this repository is no longer being updated!

Please use grace-plugins/grace-htmx, it supports both Grails 3+ and Grace 2022!

Grails with Htmx

Grails Plugin for using Grails with htmx.

Usage

Add dependency to the build.gradle,

repositories {
    mavenCentral()
}

dependencies {

    // Grails 4
    compile "org.rainboyan.plugins:grails-plugin-htmx:0.0.2"

    // Grails 5+
    implementation "org.rainboyan.plugins:grails-plugin-htmx:0.0.2"
}

Htmx plugin supports controller-specific withFormat() method,

class BookController {

    def list() {
        def books = Book.list()

        withFormat {
            htmx {
                render(template: "book", model: [bookList: books])
            }
            json {
                render books as JSON
            }
        }
    }
}

Also, this plugin supports extendsions for Grails Request and Response,

// You can get htmx request headers from Grails Request

request.htmx.boosted == request.getHeader('HX-Boosted')
request.htmx.target  == request.getHeader('HX-Target')

// Check htmx request?
if (request.htmx as boolean) { // or use request.isHtmx()
    template = 'book-detail'
}

// You can set htmx response headers in Grails

response.htmx.trigger = 'itemAdded'

Example

Development

Build from source

git clone https://github.com/rainboyan/grails-htmx.git
cd grails-htmx
./gradlew publishToMavenLocal

Support Grails Version

  • Grails 4.0, 4.1
  • Grails 5.0, 5.1, 5.2, 5.3
  • Grails 6.0

Roadmap

1.x

  • Htmx 1.9

2.x

  • Htmx 2.0

License

This plugin is available as open source under the terms of the APACHE LICENSE, VERSION 2.0

Links

grails-htmx's People

Contributors

rainboyan avatar

Stargazers

Mark Nellemann avatar Mattias Reichel avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.