Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!--- link --->
<cffunction name="link" output="false" access="public" returntype="any" hint="Create link tags, using the SES base URL or not">
<cfargument name="href" type="any" required="true" hint="The href link to link to"/>
<cfargument name="rel" type="any" required="false" default="stylesheet" hint="The rel attribute"/>
<cfargument name="type" type="any" required="false" default="text/css" hint="The type attribute"/>
<cfargument name="title" type="any" required="false" default="" hint="The title attribute"/>
<cfargument name="media" type="any" required="false" default="" hint="The media attribute"/>
<cfargument name="noBaseURL" type="boolean" required="false" default="false" hint="Defaults to false. If you want to NOT append a request's ses or html base url then set this argument to true"/>
<cfargument name="charset" type="any" required="false" default="UTF-8" hint="The charset to add, defaults to utf-8"/>
<cfargument name="sendToHeader" type="boolean" required="false" default="true" hint="Send to the header via htmlhead by default, else it returns the content"/>
var buffer = createObject("java","java.lang.StringBuffer").init("<link");
// Check if we have a base URL
arguments.href = prepareBaseLink(arguments.noBaseURL,arguments.href);
local.excludes = "noBaseURL";
if(arguments.rel == "canonical"){
local.excludes &= ",type,title,media,charset";
// build link
//Load it
if( arguments.sendToHeader AND len(buffer.toString())){
return buffer.toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment