Hi Mark,
if I do get your code right you create a "list" of author names without
commas?
In my code I join them together and remove the trailing comma and
whitespace pair with a slice before returning the text. So far this works
for my usecase but yours is way more compact which is nice I guess :)
Thanks a lot for your help and effort I am sure I will ask for more when I
dig deeper in my e-book management plugin.
Cheers
Tristan
Am Donnerstag, 14. April 2016 18:02:44 UTC+2 schrieb Mark S.:
>
> Hi Tristan,
>
> This was the export part of the code I came up with for testing:
>
> exports.run = function(text) {
>
> var vartext = "[["+text.split(",").join("]] [[")+"]]" ;
> return vartext ;
>
> };
>
> Both our approaches probably need something in there to squeeze out spaces
> after commas.
>
> Have fun!
> Mark
>
>
> On Wednesday, April 13, 2016 at 11:49:29 PM UTC-7, Tristan Kohl wrote:
>>
>> Hi Mark,
>>
>> here is my macro code:
>> /*\
>>
>> title: $:/plugins/mirodin/ebooks/linklist.js
>> type: application/javascript
>> module-type: macro
>>
>> \*/
>> (function() {
>>
>> "use strict";
>>
>> /*
>> List all field values as comma separated list of clickable links.
>> */
>>
>> exports.name = "linklist";
>>
>> exports.params = [];
>>
>> /*
>> Run the macro
>> */
>> exports.run = function(field) {
>> if (typeof field === "undefined") {
>> return "''Please pass field.''";
>> }
>> var elements = field.split(",");
>> var result = "";
>> for (var i = 0; i < elements.length; i++) {
>> result += "[[" + elements[i] + "]], ";
>> }
>> result = result.slice(0, -2);
>> return result;
>> };
>>
>> })();
>>
>> Thanks for your hint, that works for me too and the whole call is way
>> more readable.
>>
>> Cheers
>> Tristan
>>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/bb756d54-063e-4c76-9ac1-b2a275061b89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.