0 Replies Latest reply on Oct 2, 2008 9:52 PM by Dhrupadh

    confusing execution sequence in Custom tag

    Dhrupadh Level 1
      I have a custom tag file with the name make_red.cfm that makes a text passed to it to the color red.
      The calling code looks like this:

      Main page<br>
      <cf_make_red result="myVar">
      Dont mess with the Zohan!!!
      </cf_make_red>
      back to the main page<br>

      The code in make_red.cfm looks something like this:

      <cfoutput>
      <hr>
      ThisTag.ExecutionMode is #ThisTag.ExecutionMode#<br>
      ThisTag.GeneratedContent is #ThisTag.GeneratedContent#<br>
      <hr>
      <cfif ThisTag.ExecutionMode IS "Start">
      Tag start<br>
      <cfif structkeyexists(attributes,"result")>
      <cfset evaluate("caller.#attributes.result# = ""CUSTOM_TAG_COMPLETED""")>
      </cfif>
      Tag processing<br>
      <cfelseif ThisTag.ExecutionMode IS "End">
      Tag processed<br>
      <cfset ThisTag.GeneratedContent = "<font color=""red"">"&ThisTag.GeneratedContent&"</font><br>">
      The tag ends here<br>
      </cfif>
      </cfoutput>

      The output looks like this:

      Main page
      ThisTag.ExecutionMode is start
      ThisTag.GeneratedContent is
      Tag start
      Tag processing
      Dont mess with the Zohan!!!
      ThisTag.ExecutionMode is end
      ThisTag.GeneratedContent is Dont mess with the Zohan!!!
      Tag processed
      The tag ends here
      back to main page

      My question is this:
      As per the sequence of the statements in the custom tag code, the text that appears in the beginning of tag file will be printed after which the processing for the end tag happens in the <cfif>. The text passed between the <cf_make_red> and </cf_make_red> i.e. "Dont mess with the Zohan!!!" appears to be printing before the end tag executes.
      Shouldnt the text passed between the <cf_make_red> and </cf_make_red> come after the end tag is processed? Because thats where i am making the text red.

      Could someone please explain this?