Templates
Last updated
Was this helpful?
Last updated
Was this helpful?
Templates are your ' HTML and consist of valid HTML/CFML tags. This includes <cfif>, <cfloop>, etc.
Your templates must have a single outer element for CBWIRE to bind to your component and update the DOM properly. This can be any valid HTML element. Below, we are using a div element.
Below is a template with one outer element ( good ) and another with two outer elements ( bad ).
By default, CBWIRE will look in the ./wires folder for a .cfm file with the same name as your component.
To override the default implicit rendering, we can tell CBWIRE where our component template is by defining a onRender() method on our component and using the template() method.
We can pass parameters when calling template().
In this case, someVar becomes available to our template.
You can also return your template inline like so:
You access computed properties in your template by invoking the method.
You can access any global helper methods defined in your ColdBox application and any modules you have installed.
For example, suppose you've installed the cbi8n module ( an internalization module for ColdBox ). You can access its global helper methods in your template, such as the $r() method for displaying text in various languages.
You can change this default location in the settings.
You can access your from your template by calling #propertyName#.
You define on your component by using the computed annotation.
Computed properties are cached are are executed when first called. See .
Visit to find ColdBox modules for your application.