ColdBox Platform Version 2.6.4

coldbox.system.plugins
Class HTMLHelper

WEB-INF.cftags.component
        extended by coldbox.system.plugins.HTMLHelper

public class HTMLHelper
extends WEB-INF.cftags.component

A cool utility that helps you when working with HTML, from creating doc types, to managing your js/css assets, to rendering tables and lists from data


Constructor Summary
init()
 
Method Summary
 any addAsset(any asset, [boolean sendToHeader='true'])
          Add a js/css asset(s) to the html head section
 any addJSContent(any content)
          Open and close xhtml javascript tags so you can easily just add content
 any addStyleContent(any content)
          Open and close xhtml style tags so you can easily just add content
private void arrayToTable(any data, [string includes=''], [string excludes=''], any buffer)
          Convert a table out of an array
 any br([numeric count='1'])
          Generate line breaks
 any docType([string type='xhtml1-trans'])
          Render a doctype by type name: xhtml11,xhtml1-strict,xhtml-trans,xthml-frame,html5,html4-strict,html4-trans,html4-frame
private string flattenAttributes(struct target)
          flatten a struct of attributes to strings
 any heading(string title, [numeric size='1'])
          Generate header tags
 any img(any src, [string alt=''], [string class=''], [string width=''], [string height=''], [string title=''], [string rel=''], [boolean noBaseURL='false'])
          Create image tags using the SES base URL or not
 any link(string href, [string rel='stylesheet'], [string type='text/css'], [string title=''], [string media=''], [boolean noBaseURL='false'])
          Create link tags, using the SES base URL or not
 any meta(any name, [any content=''], [string type='name'])
          Helps you generate meta tags
 any nbs([numeric count='1'])
          Generate non-breaking spaces ( )
 any ol(any values='', [struct attributes='[runtime expression]'], [string column=''])
          Create ordered lists according to passed in values and arguments, compressed HTML
private boolean passIncludeExclude(string value, [string includes=''], [string excludes=''])
          checks if a list include exclude check passes
private void queryToTable(any data, [string includes=''], [string excludes=''], any buffer)
          Convert a table out of an array of structures
 any table(any data, [string includes=''], [string excludes=''], [struct attributes='[runtime expression]'])
          Convert a table out of data (either a query or array of structures or array of entities)
 any tag(string tag, [string content=''], [struct attributes='[runtime expression]'])
          Surround content with a tag
private any toHTMLList(string tag, any values='', [struct attributes='[runtime expression]'], [string column=''])
          Convert a sent in tag type to an HTML list
 any ul(any values='', [struct attributes='[runtime expression]'], [string column=''])
          Create un-ordered lists according to passed in values and arguments, compressed HTML
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init()

Method Detail

addAsset

public any addAsset(any asset, [boolean sendToHeader='true'])
Add a js/css asset(s) to the html head section. You can also pass in a list of assets via the asset argument to try to load all of them. You can also make this method return the string that will be sent to the header instead.

Parameters:
asset - The asset(s) to load, only js or css files. This can also be a comma delimmited list.
sendToHeader - Send to the header via htmlhead by default, else it returns the content

addJSContent

public any addJSContent(any content)
Open and close xhtml javascript tags so you can easily just add content

Parameters:
content - The content to render out

addStyleContent

public any addStyleContent(any content)
Open and close xhtml style tags so you can easily just add content

Parameters:
content - The content to render out

arrayToTable

private void arrayToTable(any data, [string includes=''], [string excludes=''], any buffer)
Convert a table out of an array

Parameters:
data - The array to convert into a table
includes - The columns to include in the rendering
excludes - The columns to exclude in the rendering
buffer

br

public any br([numeric count='1'])
Generate line breaks

Parameters:
count - The number of breaks

docType

public any docType([string type='xhtml1-trans'])
Render a doctype by type name: xhtml11,xhtml1-strict,xhtml-trans,xthml-frame,html5,html4-strict,html4-trans,html4-frame

Parameters:
type - The doctype to generate

flattenAttributes

private string flattenAttributes(struct target)
flatten a struct of attributes to strings

Parameters:
target

heading

public any heading(string title, [numeric size='1'])
Generate header tags

Parameters:
title - The header content
size - The header size: h1, h2, hx

img

public any img(any src, [string alt=''], [string class=''], [string width=''], [string height=''], [string title=''], [string rel=''], [boolean noBaseURL='false'])
Create image tags using the SES base URL or not

Parameters:
src - The source URL to link to or a structure of name-value pairs to use to construct the image: [src,alt,class,width,height,title,rel]
alt - The alt tag
class - The class tag
width - The width tag
height - The height tag
title - The title tag
rel - The rel tag
noBaseURL - Prepends the setting of baseURL if false

link

public any link(string href, [string rel='stylesheet'], [string type='text/css'], [string title=''], [string media=''], [boolean noBaseURL='false'])
Create link tags, using the SES base URL or not

Parameters:
href - The href link or a structure of name-value pairs to render: keys [href,rel,type,title,media]
rel - The rel attribute
type - The type attribute
title - The title attribute
media - The media attribute
noBaseURL - Prepends the setting of baseURL if false

meta

public any meta(any name, [any content=''], [string type='name'])
Helps you generate meta tags

Parameters:
name - A name for the meta tag or an array of struct data to convert to meta tags.Keys [name,content,type]
content - The content attribute
type - Either ''name'' or ''equiv'' which produces http-equiv instead of the name

nbs

public any nbs([numeric count='1'])
Generate non-breaking spaces ( )

Parameters:
count - The number of spaces

ol

public any ol(any values='', [struct attributes='[runtime expression]'], [string column=''])
Create ordered lists according to passed in values and arguments, compressed HTML

Parameters:
values - An array of values or list of values
attributes - Attributes for the enclosing OL tags
column - If the values is a query, this is the name of the column to get the data from to create the list

passIncludeExclude

private boolean passIncludeExclude(string value, [string includes=''], [string excludes=''])
checks if a list include exclude check passes

Parameters:
value - The value to test
includes - The columns to include in the rendering
excludes - The columns to exclude in the rendering

queryToTable

private void queryToTable(any data, [string includes=''], [string excludes=''], any buffer)
Convert a table out of an array of structures

Parameters:
data - The query to convert into a table
includes - The columns to include in the rendering
excludes - The columns to exclude in the rendering
buffer

table

public any table(any data, [string includes=''], [string excludes=''], [struct attributes='[runtime expression]'])
Convert a table out of data (either a query or array of structures or array of entities)

Parameters:
data - The query or array of structures or array of entities to convert into a table
includes - The columns to include in the rendering
excludes - The columns to exclude in the rendering
attributes - Attributes for the enclosing table tag

tag

public any tag(string tag, [string content=''], [struct attributes='[runtime expression]'])
Surround content with a tag

Parameters:
tag - The tag to generate
content - The content of the tag
attributes - The attributes to use in the tag

toHTMLList

private any toHTMLList(string tag, any values='', [struct attributes='[runtime expression]'], [string column=''])
Convert a sent in tag type to an HTML list

Parameters:
tag - The list tag type
values - An array of values or list of values
attributes - Attributes for the enclosing list tag
column - If the values is a query, this is the name of the column to get the data from to create the list

ul

public any ul(any values='', [struct attributes='[runtime expression]'], [string column=''])
Create un-ordered lists according to passed in values and arguments, compressed HTML

Parameters:
values - An array of values or list of values
attributes - Attributes for the enclosing UL tags
column - If the values is a query, this is the name of the column to get the data from to create the list

ColdBox Platform Version 2.6.4