Is there an equivalent CFHTMLHEAD for CFSCRIPT?

This question was asked and answered more than a year ago. Since then ColdFusion 10 has been released, but the documentation is poor. This question is strictly related to ColdFusion 10 and CFSCRIPT.

I am interested in writing this code exclusively in CFSCRIPT with absolutely no use of the CFHTMLHEAD tag.

<cffunction name="HTMLHead" output="false" returnType="void"> <cfargument name="text" type="string" required="yes"> <cfhtmlhead text="#text#"> </cffunction> 

This is how I think it should work

 // CREATE PAGE TITLE function createPageTitle(Content) { LOCAL.Content = ARGUMENTS.Content; LOCAL.Content = "<title>#LOCAL.Content#</title>"; LOCAL.Content = htmlhead(LOCAL.Content); } 

I cannot find documentation on how to do this, but it looks like this will be one of the first things to be included in CFSCRIPT.

+4
source share
3 answers

I do not think so. BUt did you watch the CFScript Community Project project on GitHub? There is an implementation of cfhtmlhead here .

+6
source

This CFScript community project project will work, but after seeing how they are implemented <cfhtmlhead> I am compressing a bit.

But I would go with the spirit of what they do and write UDF, but I just as carefully imitate how <cfhtmlhead> will be implemented as possible:

 <cffunction name="cfHtmlHead"> <cfhtmlhead attributecollection="arguments"> </cffunction> 

(I would also buy it with the tag returntype / access / output / a <cfargument> etc.).

I support CFML.cfc for my coding, which fills in the blanks for older versions of ColdFusion that I run, which don't have much CFScript readiness, but it's just a lib function full of such UDFs. I do not implement separate CFCs that need to be created, and a method called a function equivalent to a tag has nothing to do with the way the tag is called. This is a confusing and poorly designed IMO.

Mileage is changing, obviously.

+5
source

If you don’t want to return to using UDFs that complete tag-based functionality, then you can insert material that should go into the <head> block at the end of the request by looking at the output buffer, finding the closing tag </head> and inserting [stuff ] to the buffer immediately before it.

I think the output buffer lives in getPageContext().getOut() . There are some methods to make a monkey with him. Fortunately, Elliot Schrein has already done the work, and there is a comment on Ben Nadel’s blog on how to do it: http://www.bennadel.com/blog/758-ColdFusion-GetPageContext-Massive-Exploration.htm (scroll down to the third Elliott comment ).

That says ... I recommend this for a "proof of concept", and I will continue to use the tag-based UDF shell approach.

+4
source

Source: https://habr.com/ru/post/1441108/


All Articles