vpl
December 4, 2022, 2:43pm
1
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={{{ [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>
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
<$list filter=<>>
Mode
Audio
Comments
Score
<$view field="mode"/>
<$macrocall $name="db_macros_plan" opt={{{ [get[title]] }}} />
<$view field="comments"/>
<img src= {{{ [get[score_ref]] }}} />
\end
1 Like
I think we are going to need to see the full definition of your “db_macros_plan” macro.
vpl
December 5, 2022, 7:41am
3
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>";
console.log(str_return);
}
return (str_return);
};
})();
vpl
December 5, 2022, 7:57am
4
RESOLVED !!! Don’t care anymore .
Syntax error.
Thanks a lot for your time
Regards
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