[Pro] optional line break for fwAdd

Just a quick question is there line break option for:

fwAdd();

as there is for:

fwAddRaw();
fwAddRawOpt();
fwAddRawln();

Have I just missed this, in the manual somewhere?
I cant seem to see a reference for adding an optional line break when using fwAdd();

cheers max


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

Hi Max,

Yep, there is a: fwAddOpt

Joe

On 10 Oct 2012, at 12:49, max email@hidden wrote:

Just a quick question is there line break option for:

fwAdd();
as there is for:

fwAddRaw();
fwAddRawOpt();
fwAddRawln();

Have I just missed this, in the manual somewhere?
I cant seem to see a reference for adding an optional line break when using fwAdd();

cheers max


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

And, just to clarify. Opt stands for Optional, as in an optional line break if the user has their code set to More Readable.

Joe


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

Hi Jo cheers for coming back…

I know it sounds stupid but I tried that, but what I get on publish isn’t what I was expecting my example puts a link tag for an external style sheet before anything other style sheet and I wanted this line of code to be on its own line but If I use fwAddOpt I don’t get the result I expected

Here is part of the code in question:

var linkTag = fwDocument.fwTags.fwFind('link',fwItem);if (linkTag){  //check link tags exists// 
 var myTag = linkTag.fwAddEnclosing(); 
  myTag.fwAddOpt('link rel="stylesheet" type="text/css" href="'+fwParameters["CSSLocation"]+'"',myTag); }

and what this produces is something that is not completely on its own line. This is its output
(notice the link tag tacked to the end of my code:

<meta name="generator" content="Freeway 5 Pro 5.6.5"/>
<link rel="stylesheet" type="text/css" href="#"/><link rel="stylesheet" type="text/css" href="css/sheet1.css"/>
<style type="text/css">

but if I use exactly the same code but use fwAddRawOpt like this:

var linkTag = fwDocument.fwTags.fwFind('link',fwItem);if (linkTag){  //check link tags exists// 
 var myTag = linkTag.fwAddEnclosing(); 
  myTag.fwAddRawOpt('<link rel="stylesheet" type="text/css" href="'+fwParameters["CSSLocation"]+'"/>',myTag); } 

this resulting output is this:

<meta name="generator" content="Freeway 5 Pro 5.6.5"/>
<link rel="stylesheet" type="text/css" href="#"/>
<link rel="stylesheet" type="text/css" href="css/sheet1.css"/>
<style type="text/css">

so hence why I was asking have I missed something…
the only real difference between the two is fwAddRawOpt
and fwAddOpt

does that make any sense ?


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

What I have done in the past is to use a second fwAddRawOpt() (just empty) after the line of code where I add the stylesheet link. That forces a line-break if line-breaks are enabled, and ignores it otherwise. You’ll see this construction used heavily in my recent HTML5 Actions.

Walter

On Oct 10, 2012, at 10:01 AM, max wrote:

Hi Jo cheers for coming back…

I know it sounds stupid but I tried that, but what I get on publish isn’t what I was expecting my example puts a link tag for an external style sheet before anything other style sheet and I wanted this line of code to be on its own line but If I use fwAddOpt I don’t get the result I expected

Here is part of the code in question:

var linkTag = fwDocument.fwTags.fwFind(‘link’,fwItem);if (linkTag){ //check link tags exists//
var myTag = linkTag.fwAddEnclosing();
myTag.fwAddOpt(‘link rel=“stylesheet” type=“text/css” href="’+fwParameters[“CSSLocation”]+‘"’,myTag); }

and what this produces is something that is not completely on its own line. This is its output
(notice the link tag tacked to the end of my code:

but if I use exactly the same code but use fwAddRawOpt like this:

var linkTag = fwDocument.fwTags.fwFind(‘link’,fwItem);if (linkTag){ //check link tags exists//
var myTag = linkTag.fwAddEnclosing();
myTag.fwAddRawOpt(‘<link rel=“stylesheet” type=“text/css” href="’+fwParameters[“CSSLocation”]+‘"/>’,myTag); }

this resulting output is this:

so hence why I was asking have I missed something…
the only real difference between the two is fwAddRawOpt
and fwAddOpt

does that make any sense ?


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

Hi Max,
fwAdd and the variants all expect to write a tag to the output stream. Your code is writing markup which is why you are getting the default closing tag as well.

As far as Freeway is concerned you’ve just added a new tag to the page called ‘’.

Use fwAddOpt to add the link tag itself and then build the attributes on top of it. This will allow you to search for the link later in the tag tree.

var myLink = myTag.fwAddOpt("link",myTag); //adds the link tag and a reference to it

//add the attributes
myLink.rel = fwQuote("stylesheet");
myLink.type = fwQuote("text/css");

//etc

Regards,
Tim.

On 10 Oct 2012, at 15:01, max wrote:

myTag.fwAddOpt('link rel="stylesheet" type="text/css" href="'+fwParameters["CSSLocation"]+'"',myTag); }

FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


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

Hi Walter the method you have described is what I have done in the past but I always thought it was a bit of an odd thing to do… but if you are using it then I will carry on
Tim your method I am assuming is the correct way to do it and will keep that handy when I come to write the script again.

cheers Joe Walter and Tim

max


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

Max – don’t take what I wrote as gospel, I just did the expedient thing given my limited understanding of the API. I’m always learning, and hope to improve my Actions to be simpler and more robust as I do.

Walter


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

Hi Walter…
No I wont take it as gospel… :o) but if what I have done, which is the same sort of thing as you have described is ok, then for this occasion I wont bother changing it, but when I need to re-write that sort of thing again, I will take on board Tim’s Method.

cheers max


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