Categories > TinyButStrong general >

template for a javascript snippet

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: powerpop
Date: 2004-07-01
Time: 04:35

template for a javascript snippet

'      [user;block=begin]<tr><td valign=top align=left><a href=http://[var.ping_domain]user/showperson/[var.wid]/[user.userid] target=ping title=ping onclick="window.open(this.href,this.target,\'width=400,height=600,scrollbars=yes\');return false;">'+
'        <img src=http://[var.ping_domain]/[user.photo] border=0 alt=[user.displayname]></a></td></tr>[user;block=end]'+
'      [user;block=begin;nodata]<tr><td><a href=http://[var.ping_domain]user/site/joinsite.php?wid=[var.wid]>join</a></td></tr>'+

the above template is for a piece of javascript that gets used on an html page as an onclick="javascriptfile"

i am having the problem that the quotes are not matching up around the above blocks - how can i make it so that either choice results in balanced quotes for javascript - each line should have a ' ' + so that the javascript string remains intact

thanks!
By: Skrol29
Date: 2004-07-01
Time: 14:36

Re: template for a javascript snippet

Hi PowerPop,

I think you forgten the line that closes the nodata section.
But I understand the problem.

The behavior you have is normal. TBS ignores the text betweens sections of a block. In your snippet, text beween the first section, and the nodata section is ignored whenver data is empty or not.

There is a thing that should work for your problem: just stick the closing section tag and the opening nodata tag together.
Like this:
' [user;block=begin] ... '+
' ...'+
' ... [user;block=end][user;block=begin;nodata]'+
' ...'+
' ... [user;block=end]'+
By: powerpop
Date: 2004-07-02
Time: 01:33

Re: template for a javascript snippet

okay - i tried that and the quotes work but the array seems to break - here is my code:

'      [user;block=begin]<tr><td valign=top align=left><a href=http://[var.ping_domain]/ping/user/showperson/[var.wid]/[user.userid] target=ping title=ping onclick="window.open(this.href,this.target,\'width=400,height=600,scrollbars=yes\');return false;">'+
'      [user;block=begin;nodata]<tr><td><a href=http://[var.ping_domain]/ping/user/site/joinsite.php?wid=[var.wid]>join</a></td></tr>'+
'      <tr><td valign=top align=left><a href=http://[var.ping_domain]/ping/user/showperson/[var.wid]/[user.userid] target=ping title=ping onclick="window.open(this.href,this.target,\'width=400,height=600,scrollbars=yes\');return false;">'+
'        <img src=http://[var.ping_domain]/ping/[var.photo] border=0 alt="[var.displayname]"></a></td></tr>[user;block=end;nodata]'+
'        <img src=http://[var.ping_domain]/ping/[user.photo] border=0 alt=[user.displayname]></a></td></tr>[user;block=end]'+

and here is the resulting javascript when there IS data in user:

'      <tr><td valign=top align=left><a href=http://ping.net/ping/user/showperson/2/1 target=ping title=ping onclick="window.open(this.href,this.target,\'width=400,height=600,scrollbars=yes\');return false;">'+
'      Array<tr><td><a href=http://ping.net/ping/user/site/joinsite.php?wid=2>join</a></td></tr>'+
'      <tr><td valign=top align=left><a href=http://ping.net/ping/user/showperson/2/1 target=ping title=ping onclick="window.open(this.href,this.target,\'width=400,height=600,scrollbars=yes\');return false;">'+
'        <img src=http://ping.net/ping/data/userdata/1/master/person.png border=0 alt="powerpop"></a></td></tr>'+
'        <img src=http://ping.net/ping/ border=0 alt=></a></td></tr>Array'+

and here is the error message that tbs gives on the template:
TinyButStrong Error (Array value): Can't merge [user.photo] because there is no key named 'photo'. This message can be cancelled using the 'noerr' parameter.


TinyButStrong Error (Array value): Can't merge [user.displayname] because there is no key named 'displayname'. This message can be cancelled using the 'noerr' parameter.


TinyButStrong Error (Array value): Can't merge [user.userid] because there is no key named 'userid'. This message can be cancelled using the 'noerr' parameter.


TinyButStrong Error (Array value): Can't merge [user.userid] because there is no key named 'userid'. This message can be cancelled using the 'noerr' parameter.

By: Skrol29
Date: 2004-07-02
Time: 10:51

Re: template for a javascript snippet

The nodata section is embeded into the first section!
It can't work.
By: powerpop
Date: 2004-07-03
Time: 00:43

Re: template for a javascript snippet

ah yes, of course, how silly