Skip to content

Commit

Permalink
enhance debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasRu committed Aug 25, 2023
1 parent d619f5b commit 5398d78
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions components/HtmlHelper.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,29 @@ component output = false {
public function init() {
local.service = {
"version" : "0.9.4",
"debug" : false,
"startTickCount": getTickCount(),
"debug" : true,
"demarkerStart": "_1.",
"demarkerEnd" : "_2.",
"debugResult" : function( htmlstring, label = "", regexForDump ) {
// if set to debug force output!
if( service.debug ) {
writeOutput( "<hr>" & label & ":" );
if( !arguments.label=="result" ){
writeOutput( "HtmlString.Length(): " & len( arguments.HtmlString ) ) ;

}else{
writeOutput( "TimeStamp: " & ((getTickCount() - service.startTickCount)) & "ms" ) ;
service.startTickCount=getTickCount();
}

if( structKeyExists( arguments, "regexForDump" ) ) {
dump( htmlstring.reMatch( arguments.regexForDump ) );
writeOutput( "Regex: /" & encodeForHTML( arguments.regexForDump ) & "/" );
//dump( htmlstring.reMatch( arguments.regexForDump ) );

}
writeOutput( "<pre style='font-size:0.6rem;border:1px solid red;'><code>" & encodeForHTML( htmlstring ) & "</code></pre>" );

writeOutput( "<pre style='font-size:0.6rem;border:1px solid red;max-height:3rem;overflow:auto;'><code>" & encodeForHTML( htmlstring ) & "</code></pre>" );
}
},
"reduceArrayAndReplaceString": function( arrayWithElements, contentString, replaceWith ) {
Expand Down Expand Up @@ -65,9 +77,10 @@ component output = false {
"compressBlankSpaces": function( htmlcontent ) {
stringsToRemove = [];
result = arguments.htmlcontent;
service.debugResult( htmlstring = result, label = "compressBlankSpaces" );
stringsToRemove.append( result.reMatch( "[ \t]+" ), true ); // compress spaces/tabs to single spaces
result = service.reduceArrayAndReplaceString( stringsToRemove, result, " " ).reReplace( "\s+[\n\r]", chr( 10 ), "ALL" );
service.debugResult( htmlstring = result, label = "compressBlankSpaces", regexForDump = "[ \t]+" );
resure=result.reReplace( "[ \t]+", " ", "All" ).reReplace( "\s+[\n\r]+", chr( 10 ), "ALL" );
// stringsToRemove.append( result.reMatch( "[ \t]+" ), true ); // compress spaces/tabs to single spaces
// result = service.reduceArrayAndReplaceString( stringsToRemove, result, " " ).reReplace( "\s+[\n\r]+", chr( 10 ), "ALL" );
service.debugResult( htmlstring = result, label = "Result" );
return result;
},
Expand Down

0 comments on commit 5398d78

Please sign in to comment.