Skip to content

Controller

renderPartial()

renderPartial() — returns any

Available in: controller Category: Rendering Functions

Instructs the controller to render a partial view when an action completes. Partials are reusable view fragments, typically prefixed with an underscore (e.g., _comment.cfm). This function allows you to render these fragments either directly to the client or capture them as a string for further processing. You can control caching, layouts, HTTP status codes, and data-loading behavior, making it flexible for both full-page updates and AJAX responses.

NameTypeRequiredDefaultDescription
partialstringyesThe name of the partial file to be used. Prefix with a leading slash (/) if you need to build a path from the root views folder. Do not include the partial filename’s underscore and file extension.
cacheanynoNumber of minutes to cache the content for.
layoutstringnoThe layout to wrap the content in. Prefix with a leading slash (/) if you need to build a path from the root views folder. Pass false to not load a layout at all.
returnAsstringnoSet to string to return the result instead of automatically sending it to the client.
dataFunctionanynotrueName of a controller function to load data from.
statusstringno[runtime expression]Force request to return with specific HTTP status code.
1. Render a partial in the current controller's view folder
renderPartial("comment");

2. Render a partial from the shared folder
renderPartial("/shared/comment");

3. Render a partial without a layout
renderPartial(partial="/shared/comment", layout=false);

4. Render a partial and return it as a string
commentHtml = renderPartial(partial="comment", returnAs="string");

5. Render a partial with caching for 15 minutes
renderPartial(partial="comment", cache=15);

6. Render a partial with a custom HTTP status code
renderPartial(partial="comment", status="202");