[tw5] Re: Template or macro or other?

2020-08-29 Thread amreus
I wanted to say thanks to everyone and even if I do not always reply to 
every post, I do read everything and try to learn.  The explanations and 
examples are extremely helpful. So thank you again!


On Thursday, August 27, 2020 at 1:18:00 PM UTC-4 PMario wrote:

> Hi
> I needed to fix some typos in the last post.
> -m
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5d987e41-9fa4-4d10-93b4-37b9661b7e67n%40googlegroups.com.


[tw5] Re: Template or macro or other?

2020-08-27 Thread PMario
Hi
I needed to fix some typos in the last post.
-m

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1ab46b8e-7160-4395-82e1-9f99dd72a1afo%40googlegroups.com.


[tw5] Re: Template or macro or other?

2020-08-27 Thread Felicia Crow
Hi,

to add to Tony's answer: Personally I would say it depends more on your use 
case than on efficiency.

If there are multiple instances, not just one list, where for instance you 
want to have a person formatted as given in your example with nothing ever 
changing in your formatting a template would make the most sense.

Macros  in my experience make most sense when you are handling more dynamic 
content/formatting dependent on certain parameters. As an example say you 
have instances where you only want to show a persons current name and 
others where you also want to add their birth name if married. A macro call 
can handle this without having to set a field, which would be necessary for 
a template to reference it.

If there is only one instance where you have a list and want exactly this 
formatting you could also get away with having your template between the 
beginning and end tag of the list widget, using {{!!field_name}} to 
reference the fields you want to transclude as this would reference the 
field on the currentTiddler which is whatever tiddler the listwidget is 
currently rendering. Your example would then look something like this:

<$list filter="[your_filter]">
<$link /> ({!!birth-date} - {{!!death-date}})


Hope this helps you in some way.

Regards,
Felicia

On Wednesday, 26 August 2020 23:21:01 UTC+2, amreus wrote:
>
>
> Working on my genealogy wiki where each person is a tiddler.  Obviously my 
> wiki has lists of people all over the place - parents list, lists of 
> children, siblings, etc.
>
> In my lists I want to link to the person, but also show some other fields 
> such as year of birth. Something similar to:
>
> Bill Henderson (1912 - 1974)
>
> Now to the question.  To accomplish this, there appear to be 2 obvious 
> ways to generate the output:
>
> 1) {{||someTemplate}}
> 2) <$list filter="..."><>>>
>
> Not knowing the internals of TiddlyWiki, I might assume using a macro 
> would be more efficient since it only deals with exactly what is passed 
> whereas the template transclusion would parse the entire tiddler each time? 
> Is my intuition correct?  Are there better ways to do this? Is there a best 
> way? Thanks.
>
>
>
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1d6445a2-9385-4fa9-87ec-b069eb625d7fo%40googlegroups.com.


[tw5] Re: Template or macro or other?

2020-08-26 Thread TW Tones
Amreus

>From experience I can say don't worry about the more efficient just design 
for understanding. You can look at more efficient methods later if you get 
performance problems (unlikely)

I write all my templates and macros to operate on current tiddler and if I 
am listing, I typically let the currentTiddler variable change; I then have 
templates always contain

{{||templatename}} which acts on current tiddler.

In your examples
<>>>
is incorrect
<$macrocall $name=formatting_macro paramname=<>/>
will work
However you can use just 
<>
and inside it refer to $(currentTiddler)$ rather than pass it.

I am not sure your intuition is correct, it is inside the list that you are 
iterating multiple times, its when you call the macro or transclude the 
template that what it contains is evaluated, and only that. 

Regards
Tony


On Thursday, 27 August 2020 07:21:01 UTC+10, amreus wrote:
>
>
> Working on my genealogy wiki where each person is a tiddler.  Obviously my 
> wiki has lists of people all over the place - parents list, lists of 
> children, siblings, etc.
>
> In my lists I want to link to the person, but also show some other fields 
> such as year of birth. Something similar to:
>
> Bill Henderson (1912 - 1974)
>
> Now to the question.  To accomplish this, there appear to be 2 obvious 
> ways to generate the output:
>
> 1) {{||someTemplate}}
> 2) <$list filter="..."><>>>
>
> Not knowing the internals of TiddlyWiki, I might assume using a macro 
> would be more efficient since it only deals with exactly what is passed 
> whereas the template transclusion would parse the entire tiddler each time? 
> Is my intuition correct?  Are there better ways to do this? Is there a best 
> way? Thanks.
>
>
>
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/98134053-c1ad-487e-9006-7e1988b1b8b4o%40googlegroups.com.