When the TW parser unpacks {{banana}} it renders the same widget nodes as:
```
<$tiddler tiddler="banana">
<$transclude tiddler=<<currentTiddler>> field="text"/>
</$tiddler>
```

In order for your widget to invoke the same widget nodes, it has to set the 
<<currentTiddler>> variable to the same tiddler you are transcluding.

Best,
Joshua Fontany

On Sunday, May 16, 2021 at 3:11:48 PM UTC-7 [email protected] wrote:

> yeah the attached example is a minimal tiddlwyiki with a custom midget 
> showing the problem. Surely some other widgets out there are doing custom 
> transclusions. 
>
> basically in wiki text {{banana}} works within another tiddler
>
> But the js / widget code i have is not right, it does seem to be picking 
> up the template that banana is using, but not the values from within banana 
> that normally populate that template. It is using a DOM node i created from 
> the document, 
>
> Sounds like it might be the variables thing you mentioned. How do i get a 
> variables hashmap from a given tiddler?
>
> On Sunday, 16 May 2021 at 23:01:14 UTC+1 [email protected] wrote:
>
>> Also if you want to transclude a tiddler literally and not as a template, 
>> try passing a variables hashmap as part of options to makeTranscludeWidget, 
>> setting the value of currentTiddler.
>>
>> On Sunday, May 16, 2021 at 11:49:13 PM UTC+2 Saq Imtiaz wrote:
>>
>>> I assume card is a DOM node. Did you create it? If so, have you attached 
>>> it to the document somewhere?
>>>
>>> A good approach, both for debugging and for asking for assistance, is to 
>>> create a minimal test case that illustrates the problem you are facing.
>>>
>>> On Sunday, May 16, 2021 at 8:54:21 PM UTC+2 [email protected] wrote:
>>>
>>>> Actually, this is still not quite right it seems:
>>>>
>>>> I have attached an example of this still not working.
>>>>
>>>> I have a template tiddler:
>>>>
>>>> ```
>>>> created: 20210502165510840
>>>> modified: 20210502165528840
>>>> title: template_example
>>>>
>>>> | !transcluded title|  <$list filter="[list[!!title]]"><$view 
>>>> field="title"/> </$list> |
>>>> ```
>>>>
>>>> and a tiddler referencing this:
>>>>
>>>> ```
>>>> created: 20210502165510840
>>>> modified: 20210502165528840
>>>> twsr_interval: 20210504165528840
>>>> tags: fruit
>>>> title: banana
>>>>
>>>> {{||template_example}}
>>>> ```
>>>>
>>>> then in my widget i try to render the "banana" tiddler into a div i 
>>>> have created called card:
>>>>
>>>> ```
>>>>
>>>> var t = $tw.wiki.makeTranscludeWidget(tiddler, {document:document, 
>>>> mode:"block", recursionMarker:"yes" });
>>>> card.innerHTML = "";
>>>> t.render(card,null);
>>>> ```
>>>>
>>>> but it seems the transclusion is incorrect somehow, any ideas? 
>>>>
>>>> [image: キャプチャ.PNG]
>>>>
>>>>
>>>> On Monday, 10 May 2021 at 21:45:46 UTC+1 James Anderson wrote:
>>>>
>>>>> thanks again.
>>>>>
>>>>> For future google searchers:
>>>>>
>>>>> ```
>>>>> var target = _this.document.createElement("div");
>>>>> var tiddler = "the name of the tiddler you want to transclude";
>>>>> ..
>>>>> var t = $tw.wiki.makeTranscludeWidget(tiddler, {document:document});
>>>>> target.innerHTML = "";
>>>>> t.render( target, null);
>>>>> ```
>>>>>
>>>>> On Monday, 10 May 2021 at 21:35:09 UTC+1 [email protected] wrote:
>>>>>
>>>>>> I recommend looking at the source code for that method, as well as 
>>>>>> how it is used other places in the core. Either use grep on the command 
>>>>>> line, or the github search is actually pretty good: 
>>>>>> https://github.com/Jermolene/TiddlyWiki5/search?q=makeTranscludeWidget
>>>>>>
>>>>>>  If you get stuck and still can't figure it out, please post the code 
>>>>>> for your widget.
>>>>>>
>>>>>>
>>>>>> On Monday, May 10, 2021 at 10:27:17 PM UTC+2 [email protected] 
>>>>>> wrote:
>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> what does $tw.wiki.makeTranscludeWidget("fig"); actually return?  
>>>>>>> what should i be setting the contents of my DOM node to with the object 
>>>>>>> returned from this?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> James
>>>>>>>
>>>>>>> On Monday, 10 May 2021 at 13:56:31 UTC+1 [email protected] wrote:
>>>>>>>
>>>>>>>> Make a parse tree including a transclude widget or look at the 
>>>>>>>> wiki.makeTranscludeWidget method.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Monday, May 10, 2021 at 2:32:03 PM UTC+2 [email protected] 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> in a tiddler {{fig}} works transcluded into another widget, so i 
>>>>>>>>> guess i'm asking : what it the widget way of performing/rendering a 
>>>>>>>>> transclusion?
>>>>>>>>>
>>>>>>>>> On Sunday, 9 May 2021 at 19:24:54 UTC+1 James Anderson wrote:
>>>>>>>>>
>>>>>>>>>> Hello,
>>>>>>>>>>
>>>>>>>>>> I'm trying to render a tiddler within another tiddler via a 
>>>>>>>>>> widget. I have attached a basic example in which i have a widget 
>>>>>>>>>> "twsr" 
>>>>>>>>>> which will schedule tiddlers, that match the tags in the parent 
>>>>>>>>>> tiddler, to 
>>>>>>>>>> be shown in the parent for the user to grade (basically a cersion of 
>>>>>>>>>> https://en.wikipedia.org/wiki/SuperMemo in TW)
>>>>>>>>>>
>>>>>>>>>> In this case i have tiddler "study fruits" which is tagged 
>>>>>>>>>> "fruit" and "veg" it should pick up any other tiddlers tagged with 
>>>>>>>>>> these 
>>>>>>>>>> and show them in "study fruits" one by one for grading. In this 
>>>>>>>>>> example the 
>>>>>>>>>> first one it will show is the "figs" tiddler.
>>>>>>>>>>
>>>>>>>>>> I'm calling "var cnt = $tw.wiki.renderTiddler("text/html", 
>>>>>>>>>> tiddler);" in the twsr widget to render the tiddler.
>>>>>>>>>>
>>>>>>>>>> "fig" uses "Fruit Template" tiddler which is a simple tiddler 
>>>>>>>>>> containing:
>>>>>>>>>>
>>>>>>>>>> <$view field="title"/>
>>>>>>>>>>
>>>>>>>>>> If i view fig individually i see what i expect. However rendering 
>>>>>>>>>> "fig" via $tw.wiki.renderTiddler("text/html", tiddler); in "Study 
>>>>>>>>>> Fruits" 
>>>>>>>>>> is not what i expect (basically the title via the view field is 
>>>>>>>>>> missing) 
>>>>>>>>>> What is the correct way to do this?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> James
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/cf5f7d94-4c9b-47c7-988f-8a8f8c653e1cn%40googlegroups.com.

Reply via email to