Skip to content

Search tags, filters, functions and guides.

Tags / flush

Tags

flush

Close outlets so a streamed page can be sent so far.

flush closes the outlets above it. When you stream a page, everything up to flush can then be sent, instead of waiting for the render to end.

page.kiln
<html>
	<head>
		{% outlet "head" %}
		{% add to "head" %}
			<title>Home</title>
		{% endadd %}
	</head>
	{% flush %}
	<body>
		<h1>Home</h1>
	</body>
</html>
Output
<html>
	<head>
		<title>Home</title>
	</head>
	<body>
		<h1>Home</h1>
	</body>
</html>

flush outputs nothing. It closes outlets with render too, so a template gives the same HTML and the same errors whether you render or stream it.

Closed outlets

  • Each outlet above flush gets the content added to it so far, and is then closed.
  • Adding content to a closed outlet is an outlet-closed error, because that part of the page may already have been sent.
  • An add to … once tag that already added its content is fine, because it adds nothing new.
  • Outlets below flush stay open.

Put flush after the last tag that adds to the outlets above it. Components lower in the page can add to an outlet that comes after it instead, such as one before </body>.

Rules

  • flush can be used any number of times.
  • It can't be inside cache, set, apply, add to or a macro, because their content isn't part of the page yet.