Set page encoding and suppression of white spaces in Application.cfc

Hi!

I’m a web developer new to Lucee and CFML, and as soon as I started exploring the features present in these technologies I’ve found out how easy and straight forward it is to develop data-driven web apps with them.

But I came across a thing that I personally consider an issue. If I wanted to define page encoding, I had to use in every template I used in my application. The same way, I had to use the same tag to remove white spaces. Yes, I discovered that I could change the settings of default encoding and spaces directly in the server panel, but I was wondering why not allow that to be set per application in the Application.cfc like this:

component {
     this.defaultPageEncoding = "utf-8";
     this.suppressWhiteSpaces = true;
}

Another thing is create the ability to bypass some tags when it comes to white spaces in which would be interesting to maintain them such as “<pre>” for instance.

That’s it for now!

\m/

1 Like

Hi Jhonatan, welcome to our community. Really great to see new members here around showing such enthusiasm and energy :smiley:

I think your proposal is a great idea, and I think that would be a really nice to have. Don’t know if anybody of the lucee team thought already about it.

There are some different ways to do what you want to do. If I remember it correctly, some of these tags/ways (e.g. <cfprocessingdirective> or <cfsilent> ) come from a time even before components and application.cfc existed in cfml. When the modern application.cfc ( the old one was a simple application.cfm file) arrived, we developers adopted that whitespace directive tags to simply run in the code inside of our apps. But then there came the modern application.cfc and many settings of the coldfusion administrator, have been pushed to be also configurable inside of the application.cfc ( one example is also database DSN configuration). If I remember it correctly, I think Railo/Lucee was the cfengine who first did that.

One more thing: For using such tags that should work in every single page, you can call them to work directly in the application.cfc, because application.cfc has pre- and post-processors functions for your templates. You could also do it like the old classic way with cfinclude files, but I wouldn’t recommend that. However, it depends on your apps need and preference. Of course, from the perspective you’ve already mentioned, I share your opinion about having also such a setting there.

Have a very nice day.

1 Like

Welcome!

I recently filed a bug to add these settings to application.cfc, please vote for it :slight_smile:
https://luceeserver.atlassian.net/browse/LDEV-3002

2 Likes

I’ve just voted for it. Needed a century to find the voting button. Is it really only available in the old view of a ticket?

1 Like

I could’t find it 4 the life of me on mobile, but I 2nd!

1 Like