• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

include return output as string

Guest
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

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

Views

653

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

LATEST

Mate you are an absolute champion. The words I was using to search google etc found nothing leaning towards what I was after. Looks like that will do the trick.

lol and to think the example I use of mail actually has an example on the very doc page. Sorry to waste your time.

Cheers

Wes

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation