component_render
host callCapy
function component_render(name : string) bool function component_render(name : string, props : as dval) bool
Description
component_render() renders a component and writes its output straight into the current response. It returns true when it renders the component. It returns false when it cannot resolve the component.
This is the form to reach for in page layouts. component() opens a capture buffer, collects everything the component prints, and hands you a string; component_render() skips that buffer entirely. When you are only going to print the result anyway, component_render("card") does less work than print(component("card")).
Use a capturing call instead when you need the output as a value — to measure it, wrap it, store it, or decide whether to emit it at all.
Name resolution, :HANDLER suffixes, props scoping, and ONCE behaviour are identical to component(); that page documents the rules in full.
Parameters
name : a component path, optionally followed by :HANDLER
props : optional input, readable inside the component as request.props
Errors
An unresolvable component does not raise an error. Bearer sets the response status to 500 and returns false. Rendering continues.
Example
Capy
component_render("/doc/examples/card.capy:CARD", {title: "Release notes"})
Example
Capy
print("<main>")
component_render("/doc/examples/card.capy:CARD", {title: "First"})
component_render("/doc/examples/card.capy:CARD", {title: "Second"})
print("</main>", "\n")
Example
Capy
var rows := ["Ada", "Grace", "Katherine"]
for row := rows {
component_render("/doc/examples/card.capy:CARD", {title: row})
}
print("\n")