- Custom Tags in the same directory as the executing script
- Custom Tags defined in a customtag path
- Custom Tags loaded at Lucee startup
If the custom tag is in the same directory as the view template executing the tag, Lucee can find the tag with the cf prefix. Consider the following directory structure (which is the structure in the example of the intro to custom tags).
When executing the view.cfm template, and encountering the
<cf_greeting> tag, Lucee looked for any matching tags in the same directory as view.cfm.
This basic lookup mechanism is useful when custom tags are only used by one view. But when used by multiple views, not all views would necessarily be in the same directory, so there are additional methods to find the tags.
Consider this directory structure:
Here was an additional custom tag, "greeting2" which will say "Good Day" instead of "Hello":
Note: This is from a different github gist repository because gists do not support subdirectories
If view_custom_tag.cfm is looking for
<cf_greeting2> custom tag, it wont find it in the same directory as itself and will error with something like this:
So the Application.cfc needs to tell Lucee where to look:
Then when the view is executed, Lucee can find the custom tag and will output:
Good Day Jim Smith, The time is 07:04 AM
Any custom tags placed into the Lucee server context, or Web context, custom tag directory can be used. Server context tags will be available to all web contexts, while web context tags will only be available to that specific web context.
The easiest way to find these directories is with the system directory placeholders:
Place any custom tags into the library/tag directory of the server or web context, and Lucee can find them.