From: Lane S. <la...@op...> - 2005-03-11 18:30:36
|
why don't you go ahead and do this implementation? -Lane Keats Kirsch wrote: > Continuing the conversation with myself ... > > Another interesting option would be to change the #eval directive to > work with Strings as well as Macros. (I would automatically convert > the String to a StringMacro). This would be a simple change. The > only downside is that it might make it a bit harder to catch some errors. > > Then you could simply say: > > #eval $content.Data using { "contextData": $someData } > > This is kind of cool. You could even do stuff like: > > #eval "Hello, $userName" using { "userName": $User.Name } > > Keats > > Keats Kirsch wrote: > >> Looking back at the old TemplateTool code, it does what you want, but >> not in a particularly elegant way: >> >> #set $m = $Template.fromString($content.Data) >> $m.eval({ "contextData": $someData }) >> >> For some reason the MacroTemplate class doesn't implement the Macro >> interface. This would be a simple change that would allow you to say: >> >> #set $m = $Template.fromString($content.Data) >> #eval $m using { "contextData": $someData } >> >> I could make this change if anyone is interested. >> >> Keats >> >> 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... >>> >>> Thanks in advance. >>> > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Webmacro-user mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-user > |