From: Mike W. <M.W...@tr...> - 2005-03-14 07:46:38
|
Hello everybody, I use this 'evalStringTemplate' to convert text from a database (or other source) to a 'parsed' text. In the database there is a value like this: 'This is a very cool $trick'. In some kind of way we put this String in $myEvalVar #set $trick = "Super trick!" Now we can use (put's the output in the context): #evalStringTemplate $myEvalVar or #evalStringTemplate $myEvalVar to $myOutput myOutput :<BR>$myOutput And the output will be: This is a very cool Super trick! It is clean, simple and does the trick that I personally (and I also think others) need! And yes, it does not use innervar or outervar things, but I don't care. I just want the same functionality like an include, but from a string! Not a file! Before I wrote this directive, I used to save the string in a file called 'DATETIMESTAMP.inc' and then used include as template 'DATETIMESTAMP.inc' (but this is such an overkill for your system) It would be fun if this include would be used by the community! And if not, than I hope that someone likes it for personal usage. Just have fun with it! Just keep things simple! Than people will understand it, and use WebMacro! Greetings from the Netherlands, out of a town called Hillegom next to the Keukenhof, Mike Weerdenburg (Ex-colleague of Marcel Huijkman) _____ Van: web...@li... [mailto:web...@li...] Namens marcel.huijkman Verzonden: zaterdag 12 maart 2005 8:48 Aan: web...@li... Onderwerp: Re: [WebMacro-user] A WM brain bender: The solution Please don't do this via the #include directive. It's not an include and it sounds like a workaround for a specific problem! Don't misuse directive for other tasks as for where they were made for. A ex-collegue of mine made this allready and handed me the code, to see if it is good enough for the community (nice he), and I'm sure he won't mind that I put het source with this email. (and a template too!) The trick that you want: get a string from somewhere and use is as a kind of stamp and it works like this: #evalStringTemplate $myEvalVar to $myOutput myOutput :<BR>$myOutput The $myEvalVar in this example can be filled with: webmacro stuff (and yes, that's cool!) The string stays intact and the parsed string $myOutput has the result after evaluation of the $myEvalVar. Simple, efficient and just what you need. Please take a good look at it, and if it's suitable, give Mike Weerdenburg all the credits. |