Action API feature request

I would dearly love to see a way to do simple text substitution
within a fwTag context. Currently, if I want to substitute some text
within a string somewhere in a Freeway document, I have to render the
tag containing it into a string and use the native replace() function
to do the heavy lifting. This works fine, but rendering a tag to a
string means (I think) that other Actions can’t do anything further
with that tag.

How about this:

myTag.fwReplace(/matchregex/,'replacementString');

Freeway would perform an internal toHTML on the tag contents, make
the substitution, and then carry on without leaving the tag object
context. Everything would remain editable by further Action trickery.

Thoughts?

Is this already possible and I just can’t find any documentation of
the fact?

Thanks,

Walter


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Are you looking to change the tag itself?

< A href=“blah/blah.html”…>My Text< / A >

into:

< NEW href=“blah/blah.html”…>My Text< / NEW >

I would love to be able to do that easily, but I don’t think FW allows this presently.

-OR-

Change the readable text:

< a href=“blah/blah.html”…>My Text< / a >

into (search and replace ‘Text’ with ‘Dog’:

< a href=“blah/blah.html”…>My Dog< / a >

I have had success with fwTag.fwFindRaw(‘Text’). Though this performs a straight syntax match, not regex. If I remember correctly, it behaves as though the found text is a pseudo-tag that can be manipulated like any other tag (fwEnclosing, fwAdd, fwValue, etc…). I would have to dig up to see exactly how it was last used. The drawback I remember is that the text must be contiguous, no: ‘My T< span > ex < /span > t’.

Short of a true regex solution, this could be used in multi-step process: 1) convert the search scope to a string with fwToHTML(); 2) search this string with the regex to return the actual usage of the search pattern; 3) then search the genuine fwDocument with the recently found pattern.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Quoting Weaver email@hidden:

Are you looking to change the tag itself?

< A href=“blah/blah.html”…>My Text< / A >

into:

< NEW href=“blah/blah.html”…>My Text< / NEW >

I would love to be able to do that easily, but I don’t think FW allows this
presently.

You can do this at the moment simply by changing the tag’s fwTitle;


function fwAfterEndBody(){
var body = fwDocument.fwTags.fwFind(“body”, fwPage);
if (body){
body.fwTitle = “Foo”;
}
}

As for changing anything else in a tag I’ve done this in the past simply by
converting everything to a string (bad, bad, bad - but very simple and quick to
code) or by walking the tag structure and rebuilding it bit by bit to my liking
(a lot longer to do, fiddly but proud that the extra work will be appreciated
by the one other action that ‘may’ be looking at the same tag on the same
page).
Regards,
Tim.

Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

All I am looking to do is to find strings of text in the tag tree and
substitute them for something else. I would like to find them without
converting to text, and certainly without leaving them that way.

What I was working through when I asked was the new inline version of
CrowBar. I needed to find markers and replace them with a local
variable. It bugged me that there was no way to do that without
converting to text.

Walter

On Mar 3, 2008, at 8:41 PM, email@hidden wrote:

Quoting Weaver email@hidden:

Are you looking to change the tag itself?

< A href=“blah/blah.html”…>My Text< / A >

into:

< NEW href=“blah/blah.html”…>My Text< / NEW >

I would love to be able to do that easily, but I don’t think FW
allows this
presently.

You can do this at the moment simply by changing the tag’s fwTitle;


function fwAfterEndBody(){
var body = fwDocument.fwTags.fwFind(“body”, fwPage);
if (body){
body.fwTitle = “Foo”;
}
}

As for changing anything else in a tag I’ve done this in the past
simply by
converting everything to a string (bad, bad, bad - but very simple
and quick to
code) or by walking the tag structure and rebuilding it bit by bit
to my liking
(a lot longer to do, fiddly but proud that the extra work will be
appreciated
by the one other action that ‘may’ be looking at the same tag on the
same
page).
Regards,
Tim.

Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walt:

The CrowBar action sounds like a great addition.

Tim:

Thank you very much. I tried everything (else) I could think of, I must have missed fwTitle.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options