html/whitespace cleanup feature

22 views
Skip to first unread message

ElKlaaso

unread,
Dec 11, 2008, 7:52:42 AM12/11/08
to ColdBox Framework
Hi,

Im not sure if this is the right place, but it would be a good feature
for coldbox, if you could specify in the coldbox.xml.cfm the following
things:

parameters for <cfprocessingdirective pageencoding="utf-8"
suppresswhitespace="true"> tag,
so coldbox automatically wraps all layout+views in this tag.

maybe an optional cleanhtml / removewhitespace setting, which used a
method like this to clean layout+view:

<cfscript>
/**
* Replaces a huge amount of unnecessary whitespace from your HTML
code.
*
* @param sInput HTML you wish to compress. (Required)
* @return Returns a string.
* @author Jordan Clark (Jorda...@Telus.net)
* @version 1, November 19, 2002
*/
function HtmlCompressFormat(sInput)
{
var level = 2;
if( arrayLen( arguments ) GTE 2 AND isNumeric(arguments[2]))
{
level = arguments[2];
}
// just take off the useless stuff
sInput = trim(sInput);
switch(level)
{
case "3":
{
// extra compression can screw up a few little pieces of HTML, doh
sInput = reReplace( sInput, "[[:space:]]{2,}", " ", "all" );
sInput = replace( sInput, "> <", "><", "all" );
sInput = reReplace( sInput, "<!--[^>]+>", "", "all" );
break;
}
case "2":
{
sInput = reReplace( sInput, "[[:space:]]{2,}", chr( 13 ), "all" );
break;
}
case "1":
{
// only compresses after a line break
sInput = reReplace( sInput, "(" & chr( 10 ) & "|" & chr( 13 ) & ")+
[[:space:]]{2,}", chr( 13 ), "all" );
break;
}
}
return sInput;
}
</cfscript>


Is this a good idea? Should i submit this idea somewhere else?

greets,
Klaas-Jan Winkel

Sana

unread,
Dec 11, 2008, 8:01:34 AM12/11/08
to ColdBox Framework
@Klaas-Jan Winkel

White space issue been fixed by Luis, if you are interested then try
to get latest code-base from SVN.

Like your idea but what will happend when users have textarea with
fckeditor ... ?

Thanks
Sana
On Dec 11, 12:52 pm, ElKlaaso <k.win...@gmail.com> wrote:
> Hi,
>
> Im not sure if this is the right place, but it would be a good feature
> for coldbox, if you could specify in the coldbox.xml.cfm the following
> things:
>
> parameters for <cfprocessingdirective pageencoding="utf-8"
> suppresswhitespace="true"> tag,
> so coldbox automatically wraps all layout+views in this tag.
>
> maybe an optional cleanhtml / removewhitespace setting, which used a
> method like this to clean layout+view:
>
>         <cfscript>
>         /**
>         * Replaces a huge amount of unnecessary whitespace from your HTML
> code.
>         *
>         * @param sInput      HTML you wish to compress. (Required)
>         * @return Returns a string.
>         * @author Jordan Clark (JordanCl...@Telus.net)

Klaas-Jan Winkel

unread,
Dec 11, 2008, 8:02:56 AM12/11/08
to col...@googlegroups.com
Im not sure how that editor works, but text within a textarea can be
skipped ofcourse..
--
Because you're so cute, i baked you a pony

Ernst van der Linden

unread,
Dec 11, 2008, 8:03:53 AM12/11/08
to col...@googlegroups.com
Sana is right, just grap the latest version from SVN.

Ernst

Klaas-Jan Winkel

unread,
Dec 11, 2008, 8:06:50 AM12/11/08
to col...@googlegroups.com
Was there a whitespace problem with coldbox-native methods? Im not
sure im talking about that, was more talking about removing whitespace
anywhere, also in my code for example.

Ernst van der Linden

unread,
Dec 11, 2008, 8:09:37 AM12/11/08
to col...@googlegroups.com
White space management works excellent in ColdBox.
You could use it for your views maybe.

Ernst

sana ullah

unread,
Dec 11, 2008, 8:17:25 AM12/11/08
to col...@googlegroups.com
@Klaas-Jan Winkel

I got your point, your example could be a nice addition.

Can you put together things in a new coldbox plugin.

Regards
Sana

Luis Majano

unread,
Dec 11, 2008, 2:53:11 PM12/11/08
to col...@googlegroups.com
Interesting,

ColdBox 2.6.2 has update the preRender interception point to actually receive the content to be rendered. Look here: http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbWhatsNew2.62#PrerenderInterceptorReceivescontenttorender

So basically, you can just create an interceptor that executes at preRender and cleans your html to be rendered.  If you do, please contribute it to the code depot.
--
Luis F. Majano
Computer Engineer
http://www.luismajano.com
http://www.coldboxframework.com

Israel Urquiza

unread,
May 24, 2016, 3:58:42 PM5/24/16
to ColdBox Platform
I am not sure what removes the line breaks from the layouts in ColdBox, but it can causes issues with single-line javascript comments. Chrome gives an "Uncaught SyntaxError: Unexpected end of input". Unless you view the source code, or experiment commenting code out it can be difficult to pin-point the cause; the error message is not very helpful.

Sana Ullah

unread,
May 24, 2016, 4:01:48 PM5/24/16
to col...@googlegroups.com
Hi,

Try to save file as UTF-8 mode. It will display extended character or it will fix the non-uni character.

Thanks
Sana

On 24 May 2016 at 20:02, Israel Urquiza <israel....@gmail.com> wrote:
I am not sure what removes the line breaks from the layouts in ColdBox, but it can causes issues with single-line javascript comments. Chrome gives an "Uncaught SyntaxError: Unexpected end of input". Unless you view the source code, or experiment commenting code out it can be difficult to pin-point the cause; the error message is not very helpful.

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/77a87749-548e-4768-bf25-d810c8f6c065%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages