> replacenocase(stObj.body,"<name>",url.name,"ALL")
That is the way I would do it for one or two of those. You need one of
those statemtns for each thing you want to replace AND it searches the whole
string every time.
But if there were potentially a whole series of the $$var$$ things (or
potentially $$func(parms)$$) I would use a loop and a regular expression to
parse the body first and then run a routine to process all of the escaped
entities.
In fact - I have done something very similar to this before in some code we
call "maxitag" (allowing you to have psuedo embedded tags inside text
produce with a rich text editor). The "tag" can do anything you can do
inside a <CFMODULE>.
We have not included it into FarCry yet, but it basically allows you to
write a "normal" <CFMODULE> and expose it by simply dropping it into a
directory - very similar to the <CFIMPORT> or CFC concepts. In the end, we
didn't support the $$..$$ type of syntax, the maxitag syntax worked like
HTML but with square brackets. So you might get something like.....
[show var="FirstName" /]
OR
[show]FirstName[/show]
Depending on how your wrote the <CFMODULE>.
What's more, tags could be nested. So you could create up something like:
[bulletlist]
[bulletpoint]
Point 1
[/bulletpoint]
[bulletpoint]
Point 2
[/bulletpoint]
[bulletpoint]
Point 3
[/bulletpoint]
[/bulletlist]
And make it do whatever you liked (not necessarily a <UL></UL> type of
thing).
Why square brackets? Because angled brackets will get consumed in a WYSYWYG
editor. Could they be curly brackets? Yep - no reason why not. Could they
be just a single character repeated? No -because the regular expressions
used to parse the text work much easier with different start/end characters.
You could always try to modify that part of the code to try for $$..$$ if
you wanted.
It is efficient in that it runs a regular expression and creates a "tree" of
items as you might see with an XML object. The second pass then "runs" the
tree through and execution method to resolve all the calls to <CFMODULES>.
This means there is only ONE search and only ONE pass through to "replace".
The way we were using it was to allow a "container like" mechanism for
content editors to be given either simple (or complex) entities they could
include directly into their body without the need to know HTML (as such).
The dev team then only had to worry about writing the module to handle
whatever was being asked.
It has always been my intention to release this into the public domain - if
people are interested (although it may be a few weeks before I can get to -
it you want the code now, please contact me at [EMAIL PROTECTED]
and I will forward it on).
To call it you would just do something like this in FarCry (instead of
#stObj.body#).....
<CFSCRIPT>
// create a parser - only need one of these
mtParser = createObject("component","com.maxitag.parser");
// get the parser to "parse" text into an XML-like document
mtDocument = mtParser.parse(stObj.body);
// output the contents of the document as a string
WriteOutput(mtDocument.getstring());
</CFSCRIPT>
Regards,
Gary Menzel
---
You are currently subscribed to farcry-dev as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004