ColdBox 3.7.0 Layouts and localized css/js

I have an application where a variety of different views share a common layout. The layout includes a header and footer and some menu functionality and it defines the head section of the site where css is included. Each specific view has its own js and css files associated with it. When a page loads, I would like for all of the css to be loaded in the head section and all of the js to be loaded at the bottom of the page, but I do not want to include any css or js files that are not applicable to the view being loaded. Is there a way, using ColdBox, to accomplish this?

I am coming from an ASP.NET MVC background where it is possible to do this in the layout:

My App Title @RenderSection("css")

and this in the view:

@section css


This way the styles local to a view are defined in the view and merged into the layout when the view is rendered. Is there a way to accomplish something similar using ColdBox? Or is there another way to achieve the same result?


No internal method that I’ve found, but what I ended up doing was adding a method to a Request Context Decorator ( - don’t forget to configure in your config/Coldbox.cfc)



component entityname=“RequestDecorator” output=“false” extends=“coldbox.system.web.context.RequestContextDecorator” {
public void function configure(){
//set our core defaults for requests

public function addCSS(sheet,media=“all”){
var stylesheet = ‘’&chr(10);


  • Private methods


  • Default RC Variables
    private function set_defaults(){



Then I just use a method the controllers to add the sheets:




And finally render at the head of my template like so:


#event.getValue("stylesheets")# `

You can use the addAsset() method to add css or js to the header. To add things to the footer you will need to do so manually by leveraging variables like JClausen shows or announcing an interception point. I like to have a footer variable if possible. However, I think in ForgeBox there is a plugin for this already.


Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager: