Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMX support? #186

Open
razvanphp opened this issue Feb 10, 2024 · 8 comments
Open

HTMX support? #186

razvanphp opened this issue Feb 10, 2024 · 8 comments

Comments

@razvanphp
Copy link

I've got on the HTMX boat recently (apparently with a big chunk of the industry) and I think it's a match made in heaven for Yii framework, considering the renderPartial functionality built-in.

Would a contribution with some helpers and first-class support be accepted?

I'm also thinking on putting it on yii2, given that Pjax is already there... we would revive the framework use-cases so easily given the excellent capabilities of Yii to generate HTML with GridView.

Cheers,
R

@samdark
Copy link
Member

samdark commented Feb 10, 2024

What's required for it from the framework side?

@razvanphp
Copy link
Author

razvanphp commented Feb 10, 2024

The AssetBundle at least and was thinking about a widget/helper for Html/ActiveForm to create some of the attributes and links.

LE: I would also write some examples in the documentation so Yii appears in the search results caused by this hype.

@samdark
Copy link
Member

samdark commented Feb 10, 2024

Hmm... I'd like that to be separated from Html/ActiveForm packages. A separate package would do.

@xepozz
Copy link
Member

xepozz commented Feb 10, 2024

Add it as a asset to your template

  <script src="https://unpkg.com/[email protected]"></script>

Use the Button widget to generate htmx:

echo Button::tag()
            ->content('Click Me!')
            ->addAttributes([
                'hx-post' => '/clicked',
                'hx-swap' => 'outerHTML',
            ]);

Will generate the following:

<button hx-post="/clicked" hx-swap="outerHTML">
    Click Me
</button>

Didn't run it, but I hope it works this way

@xepozz
Copy link
Member

xepozz commented Feb 10, 2024

It would be great if you provide some details about what you want have: shortcuts, styling, cross-widget referencing or whatever

@razvanphp
Copy link
Author

Hmm... I'd like that to be separated from Html/ActiveForm packages. A separate package would do.

… for Yii3 makes sense as all packages are independent, but for Yii2? It’s more about promoting the technology, I know I can add the attributes already.

@vjik
Copy link
Member

vjik commented Feb 11, 2024

I think the best solution would be to create separate package (yiisoft/htmx) based on Yii HTML. We can create special classes for HTMX tags with methods, that will allow to add htmx-specific attributes. Also create HTMX widgets (if need).

@razvanphp If you feel the desire and opportunity enough do it, we help you with this.

@samdark
Copy link
Member

samdark commented Feb 11, 2024

Yii2 core feature set is frozen. Creating extensions is OK though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants