Variable in a template causes a Javascript Error

44 views
Skip to first unread message

Philippe Le Toquin

unread,
Nov 10, 2016, 2:28:27 PM11/10/16
to TiddlyWiki
Hello,

I am again probably misunderstanding something but I can't see what.

I have the following code in a tiddler to select a day of week and create a new tiddler out of it.

\define maketitle()  $(year)$ $(week)$ $(selectedday)$

\define getnumber()  <$view tiddler="dayNumber" index=$(selectedday)$ \>

!Add to the Weekly Record schedule for week <<now WW>>

Select a day :
<$select tiddler="$:/_ppmt/temp/selectday" default=<<now DDD>> >
<option>Monday</option>
<option>Tuesday</
option>
<option>Wednesday</option>
<option>Thursday</
option>
<option>Friday</option>
<option>Saturday</
option>
<option>Sunday</option>
</
$select>
&nbsp;&nbsp;
<$set name="week" value=<<now WW>> >
<$set name="year" value=<<now YYYY>> >
<$set name="selectedday" value={{$:/_ppmt/temp/selectday!!text}}>
<$set name="boo" value=<<getnumber>> >

In the tiddler it works <<boo>> but if I click on the button to create a new day then it crashes

<$maketid  title=<<maketitle>> tags="dailywork" template="$:/_ppmt/template/Daily_Records" edit="yes">
   
<$iftid tiddler=<<maketitle>> then="tm-edit-tiddler" else="tw-new-tiddler">
       
<$button message="tw-if-tiddler">
         
Create / Edit Selected day
       
</$button>
   </
$iftid>
</$maketid>
</
$set></$set></$set></$set>



The macro getnumber() is reading from a dictionnary tiddler that map the day of the week to a numbe from 1 to 7.

the value week, year, selectedday and boo are used in a template to populate some field. All was working well until I introduced the variable boo to the template. At this point I get the following error

Internal JavaScript Error

Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 750 of the JSON data

What confuses me is that the macro is working since I can use it in the tiddler above and it display the correct number but in the templates it fails :(

Philippe

Mark S.

unread,
Nov 10, 2016, 2:58:57 PM11/10/16
to TiddlyWiki
Since I don't have your 3rd party plugins, I can't try out your code. But I don't think your use of <$view> will work. See if this gives you a better result for boo:

<$set name="boo" filter="[[dayNumber]getindex{$:/_ppmt/temp/selectday}]">

Good luck,
Mark

Philippe Le Toquin

unread,
Nov 10, 2016, 3:21:01 PM11/10/16
to TiddlyWiki
Seriously!!!

I have a long way to go before I get to the level some of you have achieved. All that to say that your code is obviously working much better than mine so thanks a lot!

What kills me is that of course it is all there in the documentation. I just can't make the connection when I read it.

Hopefully I will learn eventually.

<digressing>
I want to say that I am really grateful with the help I receive from this group. Everybody is very helpful and is showing a huge amount of patience with rookies like me.

I have been browsing the thread in order to find some answers to my question and not once have I stumble upon a post where someone is being rude to someone else.
You don't get many place like that anymore. Especially in the programming world :(

So again thanks everyone
Reply all
Reply to author
Forward
0 new messages