[tw5] Re: template: where is the widget???

2021-06-28 Thread Soren Bjornstad
On Monday, June 28, 2021 at 6:15:35 PM UTC-5 jn.pierr...@gmail.com wrote:

> Thank you to both of you for your explanation. The information on the 
> system tag was very helpful.
>
> @Soren: you write tgis in your textbook:
> [...]
>

I think PMario covered everything you asked very well, let me know if 
there's anything you still wanted to know. :)

-- 
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/dbef86b1-fe52-42c8-a504-12fa7299bee3n%40googlegroups.com.


[tw5] Re: template: where is the widget???

2021-06-28 Thread PMario
On Tuesday, June 29, 2021 at 1:15:35 AM UTC+2 jn.pierr...@gmail.com wrote:

Here are some things that *change the current tiddler*:
>
>- Transcluding another tiddler with the {{curly braces}} syntax.
>- Using a $list widget to enumerate the outputs of a filter.
>- Directly setting currentTiddler with a $set or $vars widget.
>
> Does it mean that you can change the content of a var or that you stack up 
> vars, getting only the values from the top var?
>

You "stack up vars". So variables have a scope. That's the reason why we 
sometimse need a construction like this:

title: myTemplate

\define concat() $(currentTiddler)$-$(title)$

<$list filter="a b c" variable=title>
<>


Since the list-widget would "overwrite" the currentTiddler with the default 
setting we can provide a new variable name. In this case "title"
The currentTiddler is the tiddler, the code lives in. 

If you create a new tiddler named: test ... You can play with templates. 

title: test

{{myTemplate}}

---

{{||myTemplate}}

 

> Could it be used to have some kind of recursion in a safe way?
>

Yes. We use recursion a lot. eg: the toc-macros. 
 

> I was thinking of vars as immutable stuff because of the syntax that 
> declare them but no syntax to alter them otherwise.
>

As I wrote. Variables have a scope. They are valid inside the widget they 
are defined in . 

\define test() abc
\define test() xyz

<>  ... Will be xyz 

So the last one wins. The above code is a "*shortcut *of" 

<$set name=test value=abc>
<$set name=test value=xyz>

<>




Try this: 

<$set name=test value=abc>

<>

<$set name=test value=xyz>

<>




 

> And finnally, in a number of my templates, the template content is only 
> <>. It seems a bit out of touch with what your telling me with 
> what template are. In effect, myMacro is only used there. Would it b a 
> better idea to ditch the macro and have the macro body directly into the 
> template text? (yes, myMacro has no params.)
>

It depends. When your code is finished, it is probably more efficient that 
the template only contains the template text. 
But for testing the following makes sense. 

title: xTemplate

\define  myMacro() 
this code works but looks odd
\end

\define myMacro()
this code is  WIP but might look better in the end. 
\end

<>

This gives you the possibility to easily test new code, without overwriting 
your "old but working" code. ... BUT BUT BUT ... 
Once the new code works and is cleaner. You need to remove the old code. .. 
There should be only 1 "source of truth"

Otherwise you will have a nightmare to maintain your code .. trust me ;)

-mario


-- 
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/609a6264-8676-45a5-ac1d-5820fb1f33fcn%40googlegroups.com.


[tw5] Re: template: where is the widget???

2021-06-28 Thread Jean-Pierre Rivière
Thank you to both of you for your explanation. The information on the 
system tag was very helpful.

@Soren: you write tgis in your textbook:

Here are some things that *change the current tiddler*:

   - Transcluding another tiddler with the {{curly braces}} syntax.
   - Using a $list widget to enumerate the outputs of a filter.
   - Directly setting currentTiddler with a $set or $vars widget.

Does it mean that you can change the content of a var or that you stack up 
vars, getting only the values from the top var?

Could it be used to have some kind of recursion in a safe way? I was 
thinking of vars as immutable stuff because of the syntax that declare them 
but no syntax to alter them otherwise.

And finnally, in a number of my templates, the template content is only 
<>. It seems a bit out of touch with what your telling me with 
what template are. In effect, myMacro is only used there. Would it b a 
better idea to ditch the macro and have the macro body directly into the 
template text? (yes, myMacro has no params.)

regards,

-- 
Jean-Pierre
Le lundi 28 juin 2021 à 16:18:20 UTC+2, Soren Bjornstad a écrit :

> I've read in the doc that widgets are the fundamental part of tiddlywiki 
>> and that all wiki syntax sugar is finally resolved as a number of widgets.
>>
>> Use of template is only described with transclusion as {{||template}} 
>> (with tiddler or field or index before ||).
>>
>> the transclude widget has no template attribute.
>>
>> How then is done the transclusion? Shouldn't the transclude widget have a 
>> template attribute?
>>
>
> Actually, the *template *is what's being transcluded during a 
> transclusion, not the tiddler. When you transclude a tiddler through a 
> template, the current tiddler is set to that tiddler and then the template 
> is transcluded.
>
> {{Tiddler||Template}} evaluates to:
>
> <$tiddler tiddler=Tiddler>
>   <$transclude tiddler=Template/>
> 
>
> {{||Template}} doesn't change the current tiddler and so evaluates to 
> simply:
>
> <$transclude tiddler=Template/>
>
> {{Tiddler1}} is shorthand for {{Tiddler1||Tiddler1}}, and evaluates to:
>
> <$tiddler tiddler=Tiddler1>
>   <$transclude tiddler=Tiddler1/>
> 
>
> More on templates and current tiddlers 
>  
> from 
> my TiddlyWiki textbook.
>  
>
>> Also, I've come across $:/tags/ViewTemplate which is only described as: 
>> "The system tag  
>> $:/tags/ViewTemplate marks the view template." which is not very telling.
>>
> I've done tenplates tgat work fine. They are not 
>> tagged $:/tags/ViewTemplate. If I tag them as scuch, they act aout as if 
>> their content was twice included. What does $:/tags/ViewTemplate really do? 
>> How should it be used?
>>
>
> Haha, some of those tag explanations could use some work. TiddlyWiki just 
> transcludes all the tiddlers with that tag in sequence when it is rendering 
> each tiddler:
>
> <$list
>  filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]" 
> variable="listItem">
>   <$transclude tiddler=<>/>
> 
>
> So the view template is essentially a list of templates that get 
> *automatically* transcluded for every tiddler without mentioning them in 
> your wikitext. This includes things like the title, the tags bar, and so on.
>
> More on the view template 
> .
>

-- 
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/dec36e17-504d-4b05-9e10-c7884c13b836n%40googlegroups.com.


[tw5] Re: template: where is the widget???

2021-06-28 Thread Soren Bjornstad

>
> I've read in the doc that widgets are the fundamental part of tiddlywiki 
> and that all wiki syntax sugar is finally resolved as a number of widgets.
>
> Use of template is only described with transclusion as {{||template}} 
> (with tiddler or field or index before ||).
>
> the transclude widget has no template attribute.
>
> How then is done the transclusion? Shouldn't the transclude widget have a 
> template attribute?
>

Actually, the *template *is what's being transcluded during a transclusion, 
not the tiddler. When you transclude a tiddler through a template, the 
current tiddler is set to that tiddler and then the template is transcluded.

{{Tiddler||Template}} evaluates to:

<$tiddler tiddler=Tiddler>
  <$transclude tiddler=Template/>


{{||Template}} doesn't change the current tiddler and so evaluates to 
simply:

<$transclude tiddler=Template/>

{{Tiddler1}} is shorthand for {{Tiddler1||Tiddler1}}, and evaluates to:

<$tiddler tiddler=Tiddler1>
  <$transclude tiddler=Tiddler1/>


More on templates and current tiddlers 
 
from 
my TiddlyWiki textbook.
 

> Also, I've come across $:/tags/ViewTemplate which is only described as: 
> "The system tag  $:/tags/ViewTemplate 
> marks the view template." which is not very telling.
>
I've done tenplates tgat work fine. They are not 
> tagged $:/tags/ViewTemplate. If I tag them as scuch, they act aout as if 
> their content was twice included. What does $:/tags/ViewTemplate really do? 
> How should it be used?
>

Haha, some of those tag explanations could use some work. TiddlyWiki just 
transcludes all the tiddlers with that tag in sequence when it is rendering 
each tiddler:

<$list
 filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]" 
variable="listItem">
  <$transclude tiddler=<>/>


So the view template is essentially a list of templates that get 
*automatically* transcluded for every tiddler without mentioning them in 
your wikitext. This includes things like the title, the tags bar, and so on.

More on the view template 
.

-- 
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/bf3dcb60-76bd-4685-a4fd-643418e3d8c5n%40googlegroups.com.


[tw5] Re: template: where is the widget???

2021-06-28 Thread TW Tones
Jean-Pierre,

The word template is over used in tiddlywiki, mostly because of the many 
ways to do templating. There are more possible than the common ones.

   - {{tiddlername}} is like incorporating content from a template 
   containing text or code
   - {{||tiddlername}} says display tiddler name here, with the current 
   tiddler as the underlying content ie; use the current text and fields title 
   etc...
   - These are in fact just a short hand for transclusion see the 
   <$transclued widget for the long hand form, the transclude say apply this 
   tiddler here, ie use it as a template.
   - Tagging a tiddler with $:/tags/viewTemplate says please use this in 
   the core template called  "viewTemplate" as you view each tiddler, the 
   viewTemplate is a special template
   - Tagging a tiddler with $:/tags/editTemplate says please use this in 
   the  template called  "editTemplate" as you edit each tiddler , the 
   editTemplate is a special template
   - In fact in many ways macros are almost identical. When you use a macro 
   its contents are pulled into the location where you use it.
   - Then after all your content development the finial result is 
   transcluded, expanded, rendered, processed and displayed according to what 
   you asked for.

In some ways it is best to return to the English definition of template;

*A template is a form, mold, or pattern used as a guide to making 
something. Here are some examples: A ruler is a template when used to draw 
a straight line. A document in which the standard opening and closing parts 
are already filled in is a template that you can copy and then fill in the 
variable parts.*

In some ways, in code and tiddlywiki a template is simply a piece of 
reusable content. Almost everything is reusable in tiddler wiki, so almost 
everything can be used as a template.

Widgets on the other hand are very similar to html tags eg; List 
item or  but the $ indicates you are referring to a 
<$widgetname/> and like html it can have attributes which are effectively 
the parameters to the widget. Widgets are the tiddlywiki way to introduce 
code such as html may use javascript. In fact most widgets are javascript 
but with one special feature, they honor the structure of tiddlywiki, they 
do what they do but in a way the whole wiki knows how to handle changes to 
itself, it is this magic ingredient that makes a wiki so interactive, 
always up to date and maintains the user interface. Widgets are a way to 
transclude functional code in your tiddlers.

I hope this clarifies things a little.

Topes
On Monday, 28 June 2021 at 21:39:22 UTC+10 jn.pierr...@gmail.com wrote:

> Hi!
>
> I've read in the doc that widgets are the fundamental part of tiddlywiki 
> and that all wiki syntax sugar is finally resolved as a number of widgets.
>
> Use of template is only described with transclusion as {{||template}} 
> (with tiddler or field or index before ||).
>
> the transclude widget has no template attribute.
>
> How then is done the transclusion? Shouldn't the transclude widget have a 
> template attribute?
>
> Also, I've come across $:/tags/ViewTemplate which is only described as: 
> "The system tag  $:/tags/ViewTemplate 
> marks the view template." which is not very telling.
>
> I've done tenplates tgat work fine. They are not 
> tagged $:/tags/ViewTemplate. If I tag them as scuch, they act aout as if 
> their content was twice included. What does $:/tags/ViewTemplate really do? 
> How should it be used?
>
> Regards,
>
> -- 
> Jean-Pierre
>
>
>
>
>
>

-- 
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/4b26d05d-16df-429f-a4f1-7098184a87ben%40googlegroups.com.