Custom Tags

Using a Custom Tag to Make Re-Usable Code

Example file

Printing output within the custom tag

Calling HTML Custom Tag Output
<h2>My Custom Tag </h2>
<cf_mapColumns name="Steve">
Hello <cfoutput>#attributes.name#</cfoutput>!!

My Custom Tag

Hello Steve!!

Printing output after the custom tag with .caller

Calling HTML Custom Tag Output
<h2>My Custom Tag </h2>
<cf_mapColumns value=20>
<cfoutput>#newValue#</cfoutput>
<cfset caller.newValue = attributes.value * 2>

My Custom Tag

40

Get a value from the Custom Tag that was created with cfscript

Calling HTML Custom Tag Output
<h2>My Custom Tag </h2>
<cf_mapColumns pgresColName="City">
<cfoutput>#newColumn#</cfoutput>

<cfscript>
    result = '';
    col = attributes.pgresColName;

    if(col == 'bedrooms') result = 'BR';
      else if(col == 'city') result = 'CIT';
      else if(col == 'latitudeFix') result = 'LAT';
      else if(col == 'listingID') result = 'ID';
      else if(col == 'listingNumber') result = 'LN';
      else if(col == 'longitudeFix') result = 'LONG';
      else if(col == 'mlsID') result = 'MLS';
      else if(col == 'parcelNumber') result = 'PARCEL';
      else if(col == 'propertyTypeID') result = 'PTYP';
      else if(col == 'soldPrice') result = 'LP';
      else if(col == 'state') result = 'ST';
      else if(col == 'totalBaths') result = 'BTH';
      else if(col == 'zipcode') result = 'ZIP';
</cfscript>

<cfset caller.newColumn = #result#>

My Custom Tag

CIT

 

 


Stephen Lloyd 11/19/2010