Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (46 sloc) 1.79 KB

HTML Helper


The HTML Helper is a core ColdBox CFC that abstracts the creation of any HTML entity. It provides consistent and secure rendering of HTML within ColdBox applications.


{% hint style="info" %} Please check out the latest CFC Docs for all the methods available to the HTML Helper. {% endhint %}

There is no special setup needed to use it in a ColdBox application, it's already baked in. Just reference the object by the html prefix and call the desired function within any layout or view.

#html.button(name = "searchView", value = "View")#

// HTML Output
<button name="searchView" id="searchView" type="button">View<button>

By specifying the name of the element and not the id, both attributes are output using the same value. You can specify a different value for the id attribute by explicitly defining it.

// CFML w/ differnet name and id
#html.button(name = "searchView", id="id_searchView", value = "View")#

// HTML Output
<button name="searchView" id="id_searchView" type="button">View<button>

You can also pass in any attribute to the registered functions and if it does not match an argument it is passed through into the HTML element:

// CFML w/ differnet name and id
  name = "searchView", 
  value = "View",
  class = "btn btn-default"

// HTML Output
  class="btn btn-default">

Injecting the HTML Helper

You can inject the HTML helper anywhere you like by using the following registered mapping: HTMLHelper@coldbox

property name="html" inject="HTMLHelper@coldbox";
You can’t perform that action at this time.