[tw5] Re: Is it possible to automatically generate multiple templates or macros?

2021-06-22 Thread TW Tones
Si,

Comments inline


> >>> but I would expect it is a little problematic because you are making 
> use of the short form of the transclude statement 
>
> I'm assuming that by "short form" you mean using curly braces rather than 
> the transclude widget? If so how could I use the transclude widget to 
> generate multiple templates?
>

Yes, rather than curly braces you can use the tiddler widget to set a 
current tiddler and the transclude widget to name the tiddler. This allows 
you to add additional logic if an when needed.
 

>
> >>> My initial thought is to use a macro instead, even if that macro then 
> invokes a "transclusion view template" and then the transcludes the named 
> template.
> >>> 
> >>> <>
>
> Yes if this is possible then great, but how could I actually do it? I 
> would want to be able to generate a new macro for every tiddler with the 
> tag "type". As far as I can tell you can't define macros within a list 
> widget.
>

I will give this some thought, but no need for a new macro each time, just 
a macro that responds to parameters it is given. Personally I prefer to 
manage different tiddler types with a fieldname containing only one value 
eg; object-type=task rather than tags.
 

>
> >>> <> which could detect if "ingredients" is 
> defined, then if "tomatoes" is defined and provide create buttons, but once 
> created seek the ingredients and ingredient details and display as you 
> macro deems. 
>
> Thanks I did not think of this (having a single macro which takes both 
> "type" and "linked tiddler" as parameters). It's not ideal but it's an 
> option I could use as a last resort. I'm not sure what you mean by "create 
> buttons" though.
>

Well, lets say I use <> a button would appear 
to create *new-food*
 similarly

<> a button to create the task object and taskname 
instance would appear.

However if both exist just display or transclude.



> >>> An approach is to use a macro with a list widget where ingredients is 
> the name of the template the list widget uses.
>
> OK now I'm lost. Can you give an example of what you mean?
>

\define show-ingredient(ingredient)
<$list filter="[[$ingredient$]] template=ingredient>
This is ignored because the tiddler "ingredient" is used to format the 
display of ingredient(s) and the current tiddler would be tomato

\end
<>
 

>
> >>> Finally remember tiddlers (or fields for that matter) that are 
> transcluded can also transclude multiple levels deep. 
>
> Yes but I can't see what the relevance of this is. Could you add a bit 
> more detail?
>

Only that you could transclude in a transclusion in a transclusion ... if 
that helped your design. eg you can transclude a field which contains a 
transclusion. For example see the caption field in core buttons such 
as $:/core/ui/Buttons/edit

Given your questions I may do a some experiment's.

Tones

-- 
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/fb88eca5-4b57-47c2-acd4-78d8c65f5120n%40googlegroups.com.


[tw5] Re: Is it possible to automatically generate multiple templates or macros?

2021-06-22 Thread Si
 Hi Tones, thanks for your comment.

>>> but I would expect it is a little problematic because you are making 
use of the short form of the transclude statement 

I'm assuming that by "short form" you mean using curly braces rather than 
the transclude widget? If so how could I use the transclude widget to 
generate multiple templates?

>>> My initial thought is to use a macro instead, even if that macro then 
invokes a "transclusion view template" and then the transcludes the named 
template.
>>> 
>>> <>

Yes if this is possible then great, but how could I actually do it? I would 
want to be able to generate a new macro for every tiddler with the tag 
"type". As far as I can tell you can't define macros within a list widget.

>>> <> which could detect if "ingredients" is 
defined, then if "tomatoes" is defined and provide create buttons, but once 
created seek the ingredients and ingredient details and display as you 
macro deems. 

Thanks I did not think of this (having a single macro which takes both 
"type" and "linked tiddler" as parameters). It's not ideal but it's an 
option I could use as a last resort. I'm not sure what you mean by "create 
buttons" though.

>>> An approach is to use a macro with a list widget where ingredients is 
the name of the template the list widget uses.

OK now I'm lost. Can you give an example of what you mean?

>>> Finally remember tiddlers (or fields for that matter) that are 
transcluded can also transclude multiple levels deep. 

Yes but I can't see what the relevance of this is. Could you add a bit more 
detail?
On Monday, 21 June 2021 at 01:11:23 UTC+1 TW Tones wrote:

> Si,
>
> I see what you want to achieve, I think the functionality is possible 
> (perhaps not literally though), and I will give it more thought, but I 
> would expect it is a little problematic because you are making use of the 
> short form of the transclude statement, and you want that to do extra work, 
> such as making use of a template to the transcluded "template", a bit like 
> a view Template for transclusions.
>
> My initial thought is to use a macro instead, even if that macro then 
> invokes a "transclusion view template" and then the transcludes the named 
> template.
>
> <>
>
> But if you want to generalise even further
> <> which could detect if "ingredients" is 
> defined, then if "tomatoes" is defined and provide create buttons, but once 
> created seek the ingredients and ingredient details and display as you 
> macro deems.
>
> The thing is macros allow for higher levels of abstraction, the inclusion 
> of code detecting "existence" and offering to create custom tiddlers, not 
> to mention determining the formatting of the display of content. I also add 
> to macros mode or state switches, for example if the wiki has 
> $:/config/author-mode = yes then provide the new buttons if the object 
> "ingredients" or instance "tomato" do not exist, otherwise indicate a 
> missing object/ingredient.
>
> An approach is to use a macro with a list widget where ingredients is the 
> name of the template the list widget uses.
>
> Finally remember tiddlers (or fields for that matter) that are transcluded 
> can also transclude multiple levels deep.
>
> Regards
> Tones
> On Sunday, 20 June 2021 at 20:32:59 UTC+10 Si wrote:
>
>> I thought I'd give this a bump just in case there's anyone out there who 
>> missed it that can help me...
>>
>> On Tuesday, 15 June 2021 at 16:28:36 UTC+1 Si wrote:
>>
>>> I've been experimenting with using "typed" links in my wiki, inspired by 
>>> this 
>>> post 
>>>  
>>> from a few months back.
>>>
>>> For example if I want to link to a food item, but also indicate that it 
>>> is an ingredient, I write:
>>>
>>> {{tomatoes||ingredient}}
>>>
>>> Where I have the following "type" tiddler:
>>>
>>> title: ingredient
>>> tags: type
>>> text: <$link to=<><>
>>>
>>> I'm wondering if there is anyway to generalise this so that I don't 
>>> actually have to add the template to the text field of every "type" tiddler 
>>> I create? Specifically I want to leave the text field free for other 
>>> content, and also be able to use *any* tiddler with the tag "type" in 
>>> the same way. So all I would have to do is add a tiddler with the title 
>>> "ingredient" and the tag "type" and immediately be able to use it as a link 
>>> template.
>>>
>>> Alternatively maybe there is a way to generate multiple *macros* in a 
>>> similar way? A tiddler with the title "ingredient" and the tag "type" would 
>>> trigger the implicit creation of an "ingredient" macro. 
>>>
>>> I can't see how this would be possible, but I'm wondering if there's a 
>>> trick I'm missing?
>>>
>>

-- 
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

[tw5] Re: Is it possible to automatically generate multiple templates or macros?

2021-06-22 Thread Si
Hi Tones, thanks for your comment.

>>> but I would expect it is a little problematic because you are making 
use of the short form of the transclude statement 

I'm assuming that by "short form" you mean using curly braces rather than 
the transclude widget? If so how could I use the transclude widget to 
auto-generate "typed links"?
On Monday, 21 June 2021 at 01:11:23 UTC+1 TW Tones wrote:

> Si,
>
> I see what you want to achieve, I think the functionality is possible 
> (perhaps not literally though), and I will give it more thought, but I 
> would expect it is a little problematic because you are making use of the 
> short form of the transclude statement, and you want that to do extra work, 
> such as making use of a template to the transcluded "template", a bit like 
> a view Template for transclusions.
>
> My initial thought is to use a macro instead, even if that macro then 
> invokes a "transclusion view template" and then the transcludes the named 
> template.
>
> <>
>
> But if you want to generalise even further
> <> which could detect if "ingredients" is 
> defined, then if "tomatoes" is defined and provide create buttons, but once 
> created seek the ingredients and ingredient details and display as you 
> macro deems.
>
> The thing is macros allow for higher levels of abstraction, the inclusion 
> of code detecting "existence" and offering to create custom tiddlers, not 
> to mention determining the formatting of the display of content. I also add 
> to macros mode or state switches, for example if the wiki has 
> $:/config/author-mode = yes then provide the new buttons if the object 
> "ingredients" or instance "tomato" do not exist, otherwise indicate a 
> missing object/ingredient.
>
> An approach is to use a macro with a list widget where ingredients is the 
> name of the template the list widget uses.
>
> Finally remember tiddlers (or fields for that matter) that are transcluded 
> can also transclude multiple levels deep.
>
> Regards
> Tones
> On Sunday, 20 June 2021 at 20:32:59 UTC+10 Si wrote:
>
>> I thought I'd give this a bump just in case there's anyone out there who 
>> missed it that can help me...
>>
>> On Tuesday, 15 June 2021 at 16:28:36 UTC+1 Si wrote:
>>
>>> I've been experimenting with using "typed" links in my wiki, inspired by 
>>> this 
>>> post 
>>>  
>>> from a few months back.
>>>
>>> For example if I want to link to a food item, but also indicate that it 
>>> is an ingredient, I write:
>>>
>>> {{tomatoes||ingredient}}
>>>
>>> Where I have the following "type" tiddler:
>>>
>>> title: ingredient
>>> tags: type
>>> text: <$link to=<><>
>>>
>>> I'm wondering if there is anyway to generalise this so that I don't 
>>> actually have to add the template to the text field of every "type" tiddler 
>>> I create? Specifically I want to leave the text field free for other 
>>> content, and also be able to use *any* tiddler with the tag "type" in 
>>> the same way. So all I would have to do is add a tiddler with the title 
>>> "ingredient" and the tag "type" and immediately be able to use it as a link 
>>> template.
>>>
>>> Alternatively maybe there is a way to generate multiple *macros* in a 
>>> similar way? A tiddler with the title "ingredient" and the tag "type" would 
>>> trigger the implicit creation of an "ingredient" macro. 
>>>
>>> I can't see how this would be possible, but I'm wondering if there's a 
>>> trick I'm missing?
>>>
>>

-- 
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/ec2abc04-819c-4231-b823-1d88ce7244ben%40googlegroups.com.


[tw5] Re: Is it possible to automatically generate multiple templates or macros?

2021-06-20 Thread TW Tones
Si,

I see what you want to achieve, I think the functionality is possible 
(perhaps not literally though), and I will give it more thought, but I 
would expect it is a little problematic because you are making use of the 
short form of the transclude statement, and you want that to do extra work, 
such as making use of a template to the transcluded "template", a bit like 
a view Template for transclusions.

My initial thought is to use a macro instead, even if that macro then 
invokes a "transclusion view template" and then the transcludes the named 
template.

<>

But if you want to generalise even further
<> which could detect if "ingredients" is 
defined, then if "tomatoes" is defined and provide create buttons, but once 
created seek the ingredients and ingredient details and display as you 
macro deems.

The thing is macros allow for higher levels of abstraction, the inclusion 
of code detecting "existence" and offering to create custom tiddlers, not 
to mention determining the formatting of the display of content. I also add 
to macros mode or state switches, for example if the wiki has 
$:/config/author-mode = yes then provide the new buttons if the object 
"ingredients" or instance "tomato" do not exist, otherwise indicate a 
missing object/ingredient.

An approach is to use a macro with a list widget where ingredients is the 
name of the template the list widget uses.

Finally remember tiddlers (or fields for that matter) that are transcluded 
can also transclude multiple levels deep.

Regards
Tones
On Sunday, 20 June 2021 at 20:32:59 UTC+10 Si wrote:

> I thought I'd give this a bump just in case there's anyone out there who 
> missed it that can help me...
>
> On Tuesday, 15 June 2021 at 16:28:36 UTC+1 Si wrote:
>
>> I've been experimenting with using "typed" links in my wiki, inspired by 
>> this 
>> post 
>>  
>> from a few months back.
>>
>> For example if I want to link to a food item, but also indicate that it 
>> is an ingredient, I write:
>>
>> {{tomatoes||ingredient}}
>>
>> Where I have the following "type" tiddler:
>>
>> title: ingredient
>> tags: type
>> text: <$link to=<><>
>>
>> I'm wondering if there is anyway to generalise this so that I don't 
>> actually have to add the template to the text field of every "type" tiddler 
>> I create? Specifically I want to leave the text field free for other 
>> content, and also be able to use *any* tiddler with the tag "type" in 
>> the same way. So all I would have to do is add a tiddler with the title 
>> "ingredient" and the tag "type" and immediately be able to use it as a link 
>> template.
>>
>> Alternatively maybe there is a way to generate multiple *macros* in a 
>> similar way? A tiddler with the title "ingredient" and the tag "type" would 
>> trigger the implicit creation of an "ingredient" macro. 
>>
>> I can't see how this would be possible, but I'm wondering if there's a 
>> trick I'm missing?
>>
>

-- 
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/b5853e2b-ccd9-4dd6-b8a0-558a65893ffdn%40googlegroups.com.


[tw5] Re: Is it possible to automatically generate multiple templates or macros?

2021-06-20 Thread Si
I thought I'd give this a bump just in case there's anyone out there who 
missed it that can help me...

On Tuesday, 15 June 2021 at 16:28:36 UTC+1 Si wrote:

> I've been experimenting with using "typed" links in my wiki, inspired by this 
> post  
> from a few months back.
>
> For example if I want to link to a food item, but also indicate that it is 
> an ingredient, I write:
>
> {{tomatoes||ingredient}}
>
> Where I have the following "type" tiddler:
>
> title: ingredient
> tags: type
> text: <$link to=<><>
>
> I'm wondering if there is anyway to generalise this so that I don't 
> actually have to add the template to the text field of every "type" tiddler 
> I create? Specifically I want to leave the text field free for other 
> content, and also be able to use *any* tiddler with the tag "type" in the 
> same way. So all I would have to do is add a tiddler with the title 
> "ingredient" and the tag "type" and immediately be able to use it as a link 
> template.
>
> Alternatively maybe there is a way to generate multiple *macros* in a 
> similar way? A tiddler with the title "ingredient" and the tag "type" would 
> trigger the implicit creation of an "ingredient" macro. 
>
> I can't see how this would be possible, but I'm wondering if there's a 
> trick I'm missing?
>

-- 
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/c95e9e7b-b852-4b25-942b-1d7e1a61f6aen%40googlegroups.com.