reference to template's field

71 views
Skip to first unread message

Rustem

unread,
Jul 11, 2015, 1:26:24 AM7/11/15
to tiddl...@googlegroups.com
I'd like to have a field in a template tiddler, and use it's value when rendering a tiddler via the template. I know I can get currentTiddler's fields, or any tiddler's fields using the title of that tiddler. But is there a way to get template's fields without referring to it by title literally?


--R.

Andreas Hahn

unread,
Jul 11, 2015, 4:10:40 AM7/11/15
to tiddl...@googlegroups.com
Short answer: No

Long answer: Yes, the transclusion widget sets a variable called
"transclusion" that (aside some other things) also includes the name of
the template being used (I am guessing that it would in most cases). So
if you can write javascript, you may be able to devise a macro that
extracts the name of the template used that you would then be able to
use to get the template's fields. I can't think of any other way right now.

Of course, a better way of permanently making this sort of thing easier
would be to change the tiddler-widget to set an appropriate variable
containing that information. Maybe you can open a github issue about this ?

/Andreas

Jeremy Ruston

unread,
Jul 11, 2015, 10:29:07 AM7/11/15
to TiddlyWiki
Hi Andreas

Of course, a better way of permanently making this sort of thing easier would be to change the tiddler-widget to set an appropriate variable containing that information. Maybe you can open a github issue about this ?

It's an interesting idea. The transclude widget can be used to transclude any field of a tiddler, or any indexed property of a data tiddler. So, we'd need a way to not just record the title of the tiddler, but also to indicate the field or index. Perhaps "transclude-template-title", "transclude-template-field" and "transclude-template-index".

Best wishes

Jeremy.
 

/Andreas

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/55A0CF6F.3000802%40googlemail.com.

For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Reply all
Reply to author
Forward
0 new messages