Skip to content

View Helpers

contentForLayout()

contentForLayout() — returns string

Available in: controller Category: Miscellaneous Functions

Includes content for the body section, which equates to the output generated by the view template run by the request.

// 1. Include the view's generated content inside a layout file
// In `app/views/layout.cfm`, place this where the page body should appear
<!DOCTYPE html>
<html>
<head>
    <title>My App</title>
</head>
<body>
    #contentForLayout()#
</body>
</html>

// 2. Combine with includeContent to render named sections alongside the body
// In `app/views/layout.cfm`
<html>
<head>
    #includeContent("head")#
</head>
<body>
    #contentForLayout()#
    #includeContent("footer")#
</body>
</html>