Hi Luis,
the current tiddler name is stored in a variable (usually), use
var currentTiddlerName = this.getVariable("currentTiddler");
then if you want data from a field
var currentTiddler = this.wiki.getTiddler(currentTiddler);
value = currentTiddler.getFieldString("fieldname");
cheers
BJ
On Thursday, April 27, 2017 at 8:51:35 PM UTC+2, Luis Gonzalez wrote:
>
> I wrote my two first macros.
>
> The first is a WikiText macro, but I think we have no control sentences
> like *if *or *for *loop in WikiText macros. I access all the tiddler
> fields: title, text, created, modified, tags....
>
> The second is a Javascript macro because I need control sentences. But in
> it I don't know how to access to the current tiddler fields.
> I try:
>
> * return "Title: " + this.getFieldString(title);*
>
> but it does not work.
>
>
> This is the macro:
> (function(){
>
> "use strict";
>
> exports.name = "ahora";
>
> exports.params = [];
>
> exports.run = function() {
> return "Title: " + this.getFieldString(title);
> };
>
> })();
>
>
> and I call the macro in other tiddler in this way:
>
> <$macrocall $name="ahora" />
>
> I get:
>
>
> *Title: undefined *: - (
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" 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/tiddlywikidev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/3a992670-8bfe-4c89-9af5-e74525d54307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.