cfdocs
cfdocs copied to clipboard
Tag body/self closing
Some tags cannot have a body. HTML tags with that trait are called "self closing". Should we flag these tags as well?
This could be useful, but some things to consider when deciding how this should be represented:
- Most of these tags are not required to explicitly self-close (like with HTML), but for some it does matter
cftransactionhas an optional body and is required to self-close when there is no bodycfmodulehas an optional body, but self-closing has a different semantics than notcfelseandcfelseifcannot close under any circumstances
Hmmm… I don't know if it's too complicated to implement…
But if we do so, it could help with auto completion.
Yes - I agree it would be super useful to document properly. I use this in my cfml parsing as well, so right now I have a hard coded list of tags that could have inner content
cfoutput, cfmail, cfsavecontent, cfquery, cfdocument, cfpdf, cfhtmltopdf, cfhtmltopdfitem, cfscript, cfform, cfloop, cfif, cfelse, cfelseif, cftry, cfcatch, cffinally, cfstoredproc, cfswitch, cfcase, cfdefaultcase, cfcomponent, cffunction, cfchart, cfclient, cfdiv, cfdocumentitem, cfdocumentsection, cfformgroup, cfgrid, cfhttp, cfimap, cfinterface, cfinvoke, cflayout, cflock, cflogin, cfmap, cfmenu, cfmodule, cfpod, cfpresentation, cfthread, cfreport, cfsilent, cftable, cftextarea, cftimer, cftransaction, cftree, cfzip, cfwindow, cfxml
For my purposes I am looking at tags which could be a parent to another CFML tag, so the cfelse elseif as @KamasamaK has mentioned is sort of an odd case, but for my purposes they could have children (even though they cannot be closed).
So I am not sure what the best terminology is to document this, but it sounds like we should have a property named something, with multiple values. Off the top of my head closingMode which might have multiple values, such as:
requiredsuch ascftransactionneversuch ascfelseoptionalsuch ascfhttpnonesuch ascfset
this needs more thought, so feel free to add suggestions here.
Good point :+1:
Are there any edge cases which aren't covered by these four values?
I don't know if optional is placed properly in my example above, since you might also say cfset is optional:
<cfset foo = moo />
vs
<cfset foo = moo>
Probably need better terminology
@shaedrich one other thing I am thinking of, which might be useful to document here is the fact that tags like cfoutput, cfquery and cfmail will evaluate CFML expressions within the innerContent. It could just be a fifth value, but closingMode no longer makes sense as a good name for the property if so.
I think self would be a better value for cfset type tags.
If we want to cover all these traits, we'll end up naming it something like tagType or the like