Skip navigation
wes_614
Currently Being Moderated

include return output as string

Apr 19, 2012 2:52 AM

Tags: #template #object

Hey Everyone,

 

I'm new to the land of coldfsuion having come from a php background of several years. In PHP i've always had affiliations with the smarty templating engine which has a somewhat similiar style in coldfusion to cfm's if you were to call them templates.

 

I generally code in cfscript objects and in both cfscript and normal cfml can't find any way to return the result of an include (either with include in cfscript or cfinclude in a cfm) as a string.

 

We use this very often in smarty so you effectivly compile the given template and return the result as a string to display as a variable in anthher template somewhere else. I cn see that include doesn't have a return type so it's obviously in itself not the answer but if anyone knows a way of doing what i'm asking or can shed some light that would be great.

 

An example would be an email i want to send... something like...

 

<cfscript>

 

var mail = new Mail();

mail.setTo("blah blah");

mail.setSubject("the subject");

mail.setContents(this.getContents());

 

function String getContents()

{

    

     return the result of the include here from a given cfm (e.g. include "template.cfm")

 

}

 

</cfscript>

 

All help appreciated!!

 

Cheers

 

Wes

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points