coldfusioncustom-tagscoldfusion-2016

Custom tag for getSafeHTML()


I am trying to create a custom tag that has amongst other functionality the ability to clean up inner content. I am trying to decide if I should

thisTag.GeneratedContent.trim().getSafeHTML()

OR

thisTag.GeneratedContent.getSafeHTML().trim()

Is there any substantial difference between these two?


Solution

  • Safety-wise there's no difference as runs of white space are a) meaningless and b) not risky for HTML.

    So it comes down to "all things being equal" really... and the only thing I can think is that if you trim first, you're potentially passing a smaller string to getSafeHtml(), so it's doing less work. That said: I think that's a theoretical benefit, not a practical one.

    Bottom line: I don't think it matters, but trimming first makes for a slight logistical improvement.