CFML: tag `<cfinclude template="…">` creates no edge; included functions are not attached to the component (mixins)
Summary
Script-style include "x.cfm"; produces an imports edge. The tag form does not.
Our project has 246 <cfinclude template="…"> with a literal path, and none of them appears in the graph. All 9 imports edges in the index come from script includes.
Example
<!--- contens/core/baseform.cfc --->
<cfcomponent output="false">
...
<!--- shared parts of forms, lists and exports --->
<cfinclude template="formlistshared.cfm">
</cfcomponent>
formlistshared.cfmis indexed, and its functions (checkRightsPartPrepare,checkRightsPartRecords, …) appear as top-levelfunctionnodes.- There is no edge from
baseform.cfctoformlistshared.cfm. - The functions are not members of
baseformor its subclasses.
A component-level include is the common CFML mixin pattern: the included functions become methods of the including component and of every component that extends it.
Path styles seen (all literal)
| Style | Count |
|---|---|
relative to the current file (../x/y.cfm) |
128 |
same directory (formlistshared.cfm) |
67 |
mapping-rooted (/contenscms/..., depends on mapping support, see the dotted extends issue) |
46 |
Expected
- An
imports(orincludes) edge for<cfinclude template="…">, the same as for the script form. - When the include sits at component level (outside
<cffunction>), the included file's functions count as members of the component. Calls such asthis.checkRightsPartPrepare()or unqualified calls in subclasses then resolve.
Thanks for the report!
#2838 is merged to main and covers the first part. <cfinclude template="…"> now links the component, function or template it sits in to the file it includes, as the script include already did. So do cfinclude(template="…"), include template="…"; and an include inside a function. Relative paths like ../shared/helpers.cfm resolve against the including file, so they find the right file even when another file has the same name. That ships in the next release.
Treating a component-level include's functions as members of the component and its subclasses (the mixin part) is a bigger change. We're leaving this issue open for it as a feature request. Mapping-rooted paths (/contenscms/…) depend on the mapping option discussed in #2650.