Cfimport and application mappings

Hi Everyone,

I have existing custom tags cfm templates that have;
<cfimport prefix="gsn" taglib="/templateTags/">

And then we use them, with;

The docs for cfimport states;
As cfimport is a compiler directive, Application.cfc mappings won't work, but mappings configured via the web admin will.

I have two questions, please;

  1. Can someone explain this to me?
    ** How does it work if it is defined in the Lucee Admin , but not if it is in an Application.cfc mapping?
  2. Can anyone think of a way that I can implement the same behaviour and allow me to use Application .cfc mappings?

I suppose I could dispense with the prefix, and put them in a customTags sub-directory…and change to calling them without the prefix, too…

But how do you then avoid name conflicts - if you have the same customTag name in a different location?

As is always the case, THANKS!

Gavin, I’ll leave your first points to those here more familiar with the lucee engine details, but as for your last point, look at the cfmodule tag, which let’s you optionally name a folder in addition to the custom tag name.

1 Like

Thanks Charlie - great minds think alike!

I have just changed all the cfimport tags that relied on a mapping, to cffmodule, instead.
and I am not sure why - but I am surprised that it just works…
Smart fellas these language designers…

Thanks again,
I sincerely love learning new things!


Indeed. There’s often all kinds of hidden gems in cfml. ;-}

If it may help anyone else finding this discussion, this topic (of cfmodule vs using the cf_ prefix to call custom tags) is discussed further in a specific section on it in the cf developers guide.

And FWIW, I did a two-part series of articles on the topic as well (granted, at the turn of the century and in the old cfdj magazine), with even more detail than those docs (and of course more than the reference docs) which could benefit readers even today. For anyone interested, those can be read via the good ol’ wayback machine:

Calling All Custom Tags – How and why to call them different ways

Calling All Custom Tags – Part 2

Just ignore the ugly pop-up blocking the first paragraph. I may republish those as blog posts, since the info may benefit some (even if using script instead of tags. And yes, the articles do contrast custom tags to other cfml options for code reuse.) If nothing else, they can benefit folks with old code, facing challenges like Gavin shared here. And I could update them in some other ways, sure.

Anyway, it just goes to show, the more things change, the more they (in many ways may) stay the same…for better or worse. :slight_smile: