why my macro return is not rendered correctly ?

41 views
Skip to first unread message

vpl

unread,
Dec 4, 2022, 9:43:27 AM12/4/22
to TiddlyWiki
Hi,

I've the following table that list different scores (tiddlers in tiddlywiki). See bottom of this mail

This works perfectly except for the
<$macrocall $name="db_macros_plan" opt={{{ [<currentTiddler>get[title]] }}} /> execution.

This macro return what I expect, that is to say:
audio src="files/audio/cours/blues-ex-1.mp3" preload="auto" controls></audio>
But in the rendered table this appears as a the string 'audio src="files/audio/cou ...." where I expect to get the refering html5 audio element

What is my error ..??

Thanks a lot for your help
Regards


<table>
<tbody>
<tr>
<th>Mode</th><th>Audio</th><th>Comments</th><th>Score</th>
</tr>
<$list filter=<<plansDBFilter>>>
<tr>
<td><$view field="mode"/></td>
<td><$macrocall $name="db_macros_plan" opt={{{ [<currentTiddler>get[title]] }}} /></td>
<td><$view field="comments"/></td>
<td><img src= {{{ [<currentTiddler>get[score_ref]] }}} /></td>
</tr>
</$list></tbody></table>
\end


Charlie Veniot

unread,
Dec 4, 2022, 9:15:56 PM12/4/22
to TiddlyWiki
I think we are going to need to see the full definition of your "db_macros_plan" macro.

vpl

unread,
Dec 5, 2022, 2:41:38 AM12/5/22
to TiddlyWiki
Of course,
here it is:

/*\
title: $:/plugins/vpl/jazzbokMem/db_macros_plan.js
type: application/javascript
module-type: macro


\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";


/*
Information about this macro

*/
exports.name = "db_macros_plan";

exports.params = [
    {name: "opt"}
];
/*
Run the macro
*/
exports.run = function(opt) {
    var str_return = "N/A";
    console.log("db_macros_plan 0.2. opt:"+opt);
       var dbPlanTiddler = this.wiki.getTiddler(opt);
    var audio_path = dbPlanTiddler.getFieldString("audio_ref");
    if (audio_path.includes("files/audio/cours")) {
        str_return = "audio src=\""+audio_path+"\" preload=\"auto\" controls></audio>";
        console.log(str_return);
    }
    return (str_return);
};

})();

vpl

unread,
Dec 5, 2022, 2:57:08 AM12/5/22
to TiddlyWiki
RESOLVED !!! Don't care anymore .
Syntax error.

Thanks a lot for your time

Regards

Eric Shulman

unread,
Dec 5, 2022, 3:08:15 AM12/5/22
to TiddlyWiki
There's no need to use javascript for this macro.  Instead, you can create a tiddler named "$:/plugins/vpl/jazzbokMem/db_macros_plan", tagged with `$:/tags/Macro`, containing:
```
\define db_macros_plan(opt)
<$let audio_path={{$opt$!!audio_ref}}>
<$list filter="[<audio_path>search:title[file/audio/cours]]" emptyMessage="N/A">
   <audio src=<<audio_path>> preload="auto" controls></audio>
</$list>
\end
```
You can then use it exactly as you were before:
```
<$macrocall $name="db_macros_plan" opt={{{ [<currentTiddler>get[title]] }}} />
```
enjoy,
-e
Reply all
Reply to author
Forward
0 new messages