cfdocs icon indicating copy to clipboard operation
cfdocs copied to clipboard

Tag body/self closing

Open shaedrich opened this issue 6 years ago • 8 comments

Some tags cannot have a body. HTML tags with that trait are called "self closing". Should we flag these tags as well?

shaedrich avatar Jun 17 '19 08:06 shaedrich

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
  • cftransaction has an optional body and is required to self-close when there is no body
  • cfmodule has an optional body, but self-closing has a different semantics than not
  • cfelse and cfelseif cannot close under any circumstances

KamasamaK avatar Jun 17 '19 16:06 KamasamaK

Hmmm… I don't know if it's too complicated to implement…

But if we do so, it could help with auto completion.

shaedrich avatar Jun 17 '19 16:06 shaedrich

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:

  • required such as cftransaction
  • never such as cfelse
  • optional such as cfhttp
  • none such as cfset

this needs more thought, so feel free to add suggestions here.

pfreitag avatar Jun 17 '19 16:06 pfreitag

Good point :+1:

Are there any edge cases which aren't covered by these four values?

shaedrich avatar Jun 17 '19 16:06 shaedrich

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

pfreitag avatar Jun 17 '19 16:06 pfreitag

@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.

pfreitag avatar Jun 17 '19 16:06 pfreitag

I think self would be a better value for cfset type tags.

pfreitag avatar Jun 17 '19 16:06 pfreitag

If we want to cover all these traits, we'll end up naming it something like tagType or the like

shaedrich avatar Jun 17 '19 16:06 shaedrich