late-king-98305
08/31/2022, 3:25 PMlate-king-98305
08/31/2022, 3:27 PMlate-king-98305
08/31/2022, 5:40 PMlate-king-98305
08/31/2022, 5:43 PMadamant-salesmen-67924
08/31/2022, 6:24 PM$Latte_Engine->render()
or ->renderToString()
there is a 3rd method argument to only render a particular block in the template you are specifying. The answer was so obvious I didn't see it XD https://forum.nette.org/en/35395-template-fragments-in-latte#p221040 So $Latte_Engine->render('path/to/template.latte', [ 'foo' => 'bar' ], 'footer');
will only render the footer block out of the template.enough-spoon-36360
08/31/2022, 7:06 PMenough-spoon-36360
08/31/2022, 8:09 PMgifted-london-36179
08/31/2022, 11:20 PMtall-river-23601
09/01/2022, 7:41 AMbrave-dog-98297
09/01/2022, 8:45 AM_="on click
...
then call htmx.process(last <.item/>)
then call _hyperscript.processNode(last <.item/>)"
fierce-application-41107
09/01/2022, 9:09 AMfierce-application-41107
09/01/2022, 9:10 AMfierce-application-41107
09/01/2022, 9:10 AMfierce-application-41107
09/01/2022, 9:11 AMhx-target="#results"
hx-swap="innerHTML"
fierce-application-41107
09/01/2022, 9:11 AMfierce-application-41107
09/01/2022, 9:12 AMbland-coat-6833
09/01/2022, 9:56 AMjinja
{% if request.htmx %}{% extends 'layout.html %}{% endif %}
{% block content %}
<button type="button" class="button">A button</button>
{% endblock %}
Then I can render just the button
if it's an htmx request. Otherwise I get the whole page back. Plus then any layout updates only need to happen in one file.
Do I end up with a load of template fragments? Yep. Can't really see a way around that.bland-coat-6833
09/01/2022, 10:40 AMmysterious-toddler-20573
09/01/2022, 1:03 PMmysterious-toddler-20573
09/01/2022, 1:03 PMmysterious-toddler-20573
09/01/2022, 1:04 PMmysterious-toddler-20573
09/01/2022, 1:05 PMbland-coat-6833
09/01/2022, 1:07 PMmysterious-toddler-20573
09/01/2022, 1:11 PMmysterious-toddler-20573
09/01/2022, 1:11 PMbland-coat-6833
09/01/2022, 1:32 PMrender()
function but then also giving it a fragment name. I think the jinja approach I've been doing is almost the reverse, it'll render just the fragment but expand out to the full page if it's not an htmx request (or whatever)mysterious-toddler-20573
09/01/2022, 1:33 PMmysterious-toddler-20573
09/01/2022, 1:33 PMmysterious-toddler-20573
09/01/2022, 1:33 PMmysterious-toddler-20573
09/01/2022, 1:34 PM