House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Parse cfm templates stored in a variable?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hello!
Peter Mayer
06/20/03 06:18 A
Mathew,
Andre Mohamed
06/20/03 08:30 A
> Actually you can evaluate functions too e.g.
Matthew Walker
06/20/03 08:51 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Mayer
06/20/2003 06:18 AM

Hello! I am reading files using cffile and storing them in a application variable (because they are very often accessed). If the file is a cfm template I would like to "execute" it - is there a simple way to do that? The only solution I've seen so far would be to save the application variable to a file and than do a cfinclude with that temporary file. Best regards, Peter

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andre Mohamed
06/20/2003 06:59 AM

There is no alternative but to "include" the file. However, if the code is all cfscript, it would technically be possible to "evaluate" the whole lot at run time. André Hello! I am reading files using cffile and storing them in a application variable (because they are very often accessed). If the file is a cfm template I would like to "execute" it - is there a simple way to do that? The only solution I've seen so far would be to save the application variable to a file and than do a cfinclude with that temporary file. Best regards, Peter

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew Walker
06/20/2003 07:36 AM

Actually you can only evaluate expressions, not whole chunks of cfscript such as loops, functions, etc. What's wrong with cfincluding them? Also BTW instead of using cffile why not simply use cfsavecontent and cfinclude? Perhaps you might consider cfincluding the CF templates and caching the result for a given period of time? Regards, Matthew Walker Electric Sheep Web http://www.electricsheep.co.nz/ ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andre Mohamed
06/20/2003 08:30 AM

Mathew, Actually you can evaluate functions too e.g. #Evaluate(Len('foo'))# Naturally, you can’t easily deal with loop constructs or conditional logic. When I said it would technically be possible - I meant it would be possible by using a suitable mechanism e.g. You could parse the file by semi-colon and then "Evaluate" each line e.g. If the file contained this: Foo = 'bar'; Bar = 'foo'; Baz = Left(foo & bar,3); Then you could turn that into: Evaluate("foo = 'bar'","Bar = 'foo'","Baz = Left(foo & bar,3)"); Or a separate Evaluate for each line. I have done this successfully in the past when it was advantageous to allow a knowledgable user to enter some scripting which could then get executed at run time - much like you would do with VBScript/Javascript. HOWEVER, this is all way too much for what the original question was. It all depends on the context of why the include files are being put into the application scope for in the first place. If they are being held there to be used dynamically whereby the output or result of the include is going to be different each time (this is what I understood) then caching the output using cfsavecontent is not an appropriate solution. If, however, it is the output of the include that needs to be cached then using cfsavecontent to save the output is obviously the way to go. Under any circumstances it makes no sense to "read" the file in using cffile only to have to write it out again when you want to include it! The most suitable approach is just to cfinclude the file as needed. Regards, André Actually you can only evaluate expressions, not whole chunks of cfscript such as loops, functions, etc. What's wrong with cfincluding them? Also BTW instead of using cffile why not simply use cfsavecontent and cfinclude? Perhaps you might consider cfincluding the CF templates and caching the result for a given period of time? Regards, Matthew Walker Electric Sheep Web http://www.electricsheep.co.nz/ ----- Excess quoted text cut - see Original Post for more ----- a ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew Walker
06/20/2003 08:51 AM

> Actually you can evaluate functions too e.g. Right. I think I meant function declarations rather than invocations -- too late on a Friday night for me. ;-)

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andre Mohamed
06/20/2003 09:48 AM

Yes, I realised during lunch - just now - that's probably what you meant! > Actually you can evaluate functions too e.g. Right. I think I meant function declarations rather than invocations -- too late on a Friday night for me. ;-)


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference