From: Alex Twisleton-Wykeham-F. <al...@fi...> - 2005-03-11 13:39:07
|
On Friday 11 March 2005 13:16, Marc Palmer wrote: > Hi, > > Long time no speak! > > I finally got around to getting 2.0b1 (only a year late!) and am working > on the start of CMS using WM. > > I wonder if I'm being really stupid, but I want some of the content, > which is pulled in from String data, to be treated as a WM template. > > So given a content string loaded from the CMS, say "<p>Hello, > $name</p>", I want to use this in my page, a template itself, but have > $name evaluate. i.e. something like this in the main CMS rendering > template: > > <div> > #eval $content.Data using { "contextData": $someData } > </div> > > ...but eval only works with Macro objects to my knowledge. > > Does anybody know how I can do this? I effectively want the same as > #include but from a String instead of a file. > > I've tried: > > <div> > #templet $block > $content.Data > #end > #eval $block using { "contextData": $someData } > </div> > > ...but of course this is not correct as $content.Data is not evaluated > at the time the templet is defined. I also tried #setblock as macro etc. > > It's a bit confusing. I'd like to not have to write a helper/directive > to load a Macro tempalte from a String unless I have to... Would it not be possible to have an implementation of TemplateProvider that used the name of the template as the contents of the template itself? This would let you say:- #include as template "<p>Hello, $name</p>" or #include as template "$templateSource" Of course, this would rather cripple your normal template loading, so there could be a switch which looked for a given header such as:- #include as template "evaluate:$templateSource" and if it didn't start with "evaluate:" then it would just delegate the request to the default template loader. If this fixed your problem then it would be relatively easy to implement... Alex |