HTMX support?
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
What's required for it from the framework side?
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.
Hmm... I'd like that to be separated from Html/ActiveForm packages. A separate package would do.
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
It would be great if you provide some details about what you want have: shortcuts, styling, cross-widget referencing or whatever
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.
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.
Yii2 core feature set is frozen. Creating extensions is OK though.