Back
includePartial()
1. If we're in the "sessions" controller, Wheels will include the file "app/views/sessions/_login.cfm".
#includePartial("login")#
2. Wheels will include the file "app/views/shared/_button.cfm".
#includePartial(partial="/shared/button")#
3. If we're in the "posts" controller and the "posts" variable includes a query result set, Wheels will loop through the record set and include the file "app/views/posts/_post.cfm" for each record.
<cfset posts = model("post").findAll()>
#includePartial(posts)#
4. We can also override the template file loaded for the example above.
#includePartial(partial="/shared/post", query=posts)#
5. The same works when passing a model instance.
<cfset post = model("post").findByKey(params.key)> #includePartial(post)#
#includePartial(partial="/shared/post", object=post)#
6. The same works when passing an array of model objects.
<cfset posts = model("post").findAll(returnAs="objects")>
#includePartial(posts)#
#includePartial(partial="/shared/post", objects=posts)#
</cfoutput>
Copied!