Last active
December 23, 2015 22:39
-
-
Save adamcameron/6704259 to your computer and use it in GitHub Desktop.
Proof of concept of making a <cfoutput>-performing custom tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Content before<br> | |
<cfset msg = "Content within"> | |
<cf_withoutput callback="#toUpper#"> | |
#msg#<br> | |
</cf_withoutput> | |
Content after<br> | |
<cfscript> | |
function toUpper(string){ | |
return ucase(string); | |
} | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
if (thistag.executionMode == "END"){ | |
structAppend(variables, caller); | |
thisDir = getDirectoryFromPath(getCurrentTemplatePath()); | |
fileName = createUuid(); | |
filePath = thisDir & fileName; | |
try { | |
fileWrite(filePath, "<cfoutput>" & thistag.generatedContent & "</cfoutput>"); | |
savecontent variable="content"{ | |
include fileName; | |
} | |
writeOutput(attributes.callback(content)); | |
} | |
catch (any e){ | |
rethrow; | |
} | |
finally { | |
if (fileExists(filePath)){ | |
try { | |
fileDelete(filePath); | |
} catch(any ignore){ | |
// oh well: I tried | |
} | |
} | |
} | |
thistag.generatedcontent = ""; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment