/*\
title: daMacro
type: application/javascript
module-type: macro
Macro that removes the path part of an absolute filename
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "removepath";
exports.params = [{name:"filename"}];
/*
Run the macro
*/
exports.run = function(filename) {
return filename.substr(filename.lastIndexOf('/')+1);
};
})();
I have a simple macro that returns me a file name without path for a given full path file name. The problem is that, some results are getting wikified.This is a big problem because I want to use the result of the macro as the text of a button. But instead of firing the button, it is navigating to the camel case title.
If you use <$text text=...> to render the macro results as a button label, then it won't get wikified.
So, instead of:<$macrocall $name="removepath" filename="path/to/GettingStarted.tid"/>try this:<$text text=<<removepath filename:"path/to/GettingStarted.tid">>/>
I have to use the macro-call widget because I'm not passing the parameter as a fixed string. I'm using the <<currentTiddler>> variable as input of the macro. Is there any other way I can do it? Maybe I can mimic the behavior of the text widget?
<$vars filename=<<currentTiddler>>><$text text=<<removepath>>/></$vars>
<$vars filename=<<currentTiddler>>>
<$set name="fancy" filter="[<removepath>removesuffix[.tid]">
with: <<fancy>>
</$set>
</$vars>
like this:
<$macrocall $name="removepath" filename="path/to/GettingStarted.tid" $type="text/plain"/>
I think, perhaps a bit annoyingly so, the way to go is to use a variable and not a parameter...
<$vars filename=<<currentTiddler>>><$text text=<<removepath>>/></$vars>