Multiple widgets from template transclusion

57 views
Skip to first unread message

Paul Lee

unread,
Nov 21, 2019, 8:30:40 PM11/21/19
to TiddlyWiki
Why will only one <$view> widget from my template tiddler show up in the tiddlers that transclude the template?

I have data stored in fields in my tiddlers, and I want those fields to be rendered into the tiddler based on the template that I transclude inside each tiddler. However, I can only ever get this to work with once in each tiddler. The first time I reference a field with the <$view> widget, it is correctly displayed, but subsequent attempts to reference different fields simply do not show up. I tested using a different widget, <$text>, and that widget also only appears if it is the first widget in a tiddler.

How do I get multiple widgets to show up in the same tiddler?

I have this in my template tiddler:

 
//<$view field="caption">//


''Year of birth: <$view field="birth-year">''


''Year of death: <$view field="death-year">''

The tiddlers transclude this template successfully, but with this code, only the value of the child tiddlers' "caption" field is displayed, unless that line in deleted from the template, in which case only the "birth-year" field is rendered.

How can I render multiple widgets using one template?

Thanks much.

Mark S.

unread,
Nov 21, 2019, 10:40:08 PM11/21/19
to TiddlyWiki
Under HTML5 all tags have to either be self-closed or have matching closing tags.

Widgets work just like html tags. So each <$view> widget needs to be closed on the end. e.g.

<$view field="caption" />

HTH

TonyM

unread,
Nov 21, 2019, 11:40:37 PM11/21/19
to TiddlyWiki
Also what is intended by the use of "// widget //"

as mark says and I think /> is not sufficient to close the view widget. Use <$view Params ></$view>

Eric Shulman

unread,
Nov 22, 2019, 12:30:56 AM11/22/19
to TiddlyWiki
On Thursday, November 21, 2019 at 8:40:37 PM UTC-8, TonyM wrote:
Also what is intended by the use of "// widget //"

as mark says and I think /> is not sufficient to close the view widget. Use <$view Params ></$view>


All widgets that don't require content inside them *can* use the self-closing "/>" syntax. Thus, <$view ... /> without a matching </$view> is totally acceptable.

Also, the //...// surrounding the <$view field="caption"/> simply makes it italic.

-e

TonyM

unread,
Nov 22, 2019, 12:52:54 AM11/22/19
to TiddlyWiki
Off course, face palm

Paul Lee

unread,
Nov 22, 2019, 3:40:30 AM11/22/19
to TiddlyWiki
Confirmed. That was the issue. <$view field="caption" /> allows for the subsequent widgets to also show up. Thanks for answering.
Reply all
Reply to author
Forward
0 new messages