Questions about the genesis widget

I started a wiki post in an attempt to help understand the genesis widget, this thread is to discuss about it / ask questions.

Here’s mine:

How can we use these attributes ?

These attributes are reserved for the core in case the genesis widget is extended with further explicit attributes.

What are you trying to achieve?

1 Like

Ah I see ! I’m simply trying to understand how to use this new widget, it seems like many here (myself included) has some difficulties understanding how to make a full use of it :slight_smile:

I might have found a bug with the genesis widget, or maybe I’m just using it wrong.

I am trying to assign variables and values to a let widget generated by the genesis widget, but it’s not working. I managed to do this with string substitution and was hoping the genesis widget could be used instead.

Here’s my code :

\define text-sample()
lorem ipsum lorem ipsum <mark attr1="string1" attr2="string2">some text</mark> lorem ipsum <mark>some text</mark> wdwd
\end

<$list filter="[<text-sample>split[<mark]split[</mark]!is[blank]]:filter[<index>add[1]remainder[2]match[0]]" variable="highlight">
<$let
text={{{ [<highlight>split[>]last[]]  }}}
names="""[<highlight>split[>]first[]split[=]split["]!is[blank]!match[]]:filter[<index>add[1]remainder[2]!match[0]] +[trim[ ]format:titlelist[]join[ ]]"""
values="""[<highlight>split[>]first[]split[=]split["]!is[blank]!match[]]:filter[<index>add[1]remainder[2]match[0]] +[trim[ ]format:titlelist[]join[ ]]"""
>

* names : {{{ [subfilter<names>] }}} <!-- output = attr1 attr2 -->
* values: {{{ [subfilter<values>] }}} <!-- output = string1 string2 -->

<$genesis $type="$let" $names=<<names>> $values=<<values>> >

* attr1= <<attr1>> <!-- no output ! Expected: string1 -->
* attr2= <<attr2>> <!-- no output ! Expected: string2 -->

</$genesis>

</$let>
<hr/>
</$list>

Any idea why ?

https://demos.tiddlyhost.com/#Dynamic%20let%20widget%20with%20genesis%20widget

Maybe it will help you to work backwards from simple, concrete filters towards the more complicated filter you have.

For example, this works as expected:

* names : {{{ attr1 attr2 }}} <!-- output = attr1attr2 -->
* values: {{{ string1 string2 }}} <!-- output = string1string2 -->

<$genesis $type="$let" $names="attr1 attr2" $values="string1 string2" >

* attr1= <<attr1>> <!-- output = string1 -->
* attr2= <<attr2>> <!-- output = string2 -->

</$genesis>

In the above, I’m using simple, concrete filters attr1 attr2 and string1 string2 and it is working fine. I’m guessing your filters are not returning what you expect and figuring out that discrepancy should help.

I know you are trying to learn about the genesis widget here, but did you also know there is a $setmultiplevariables which can do the same thing as above? Interesting that it can also be implemented with $let + $genesis

<$setmultiplevariables $names="attr1 attr2" $values="string1 string2">

* attr1= <<attr1>> <!-- output = string1 -->
* attr2= <<attr2>> <!-- output = string2 -->

</$setmultiplevariables>
1 Like

Thanks, I found the issue ! I shouldn’t have used a join operator :

\define text-sample()
lorem ipsum lorem ipsum <mark attr1="string1" attr2="string2">some text</mark> lorem ipsum <mark>some text</mark> wdwd
\end

<$list filter="[<text-sample>split[<mark]split[</mark]!is[blank]]:filter[<index>add[1]remainder[2]match[0]]" variable="highlight">

<$genesis $type="$let" $names="""[<highlight>split[>]first[]split[=]split["]!is[blank]!match[]]:filter[<index>add[1]remainder[2]!match[0]]+[trim[ ]]""" $values="""[<highlight>split[>]first[]split[=]split["]!is[blank]!match[]]:filter[<index>add[1]remainder[2]match[0]]+[trim[ ]]""" >

* attr1= <<attr1>>
* attr2= <<attr2>>

</$genesis>

<hr/>
</$list>

I very rarely used that widget so I forgot it existed, thanks for reminding me ! Maybe this widget is obsolete now, since the genesis widget can do the same thing and more…

Thank you @telumire. A very useful thread

In

\define link(to)
<$let 
search={{{ [<__to__>minlength[3]]:map[all[tiddlers+shadows]search:title<__to__>] }}}
>
<$genesis 
$type={{{ [<search>is[tiddler]then[$link]else[a]] }}}
$names="[<search>is[tiddler]then[to]else[href]] class"
$values="[<search>is[tiddler]else<__to__>] [<search>!is[tiddler]then[tc-tiddlylink-external]]"
>
<$text text=<<__to__>>/>
</$genesis>
</$let>
\end

I would recommend using (search: is removed)

search={{{ [<__to__>minlength[3]]:map[all[tiddlers+shadows]title<__to__>] }}}

instead of

search={{{ [<__to__>minlength[3]]:map[all[tiddlers+shadows]search:title<__to__>] }}}

What you think if target=_blank is added to $genesis?

Then for below examples on tiddlywiki.com we have

<<link HelloThere>>

<<link "https://yahoo.com">>

Generates raw html

<p>
<a class="tc-tiddlylink tc-tiddlylink-resolves" href="#HelloThere">
HelloThere
</a>
</p><p>
<a class="tc-tiddlylink-external" href="https://yahoo.com" target="_blank">
https://yahoo.com
</a>
</p>

I use search in that example to be able to have some sort of “fuzzy link”, otherwise the default wikitext link does the same thing :slight_smile: For example, if there is a tiddler called My Tiddler, we can link to it with <<link "my tiddler">>.

Good idea, and we could also add the other attributes defined in https://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Fparsers%2Fwikiparser%2Frules%2Fextlink.js

Or maybe it would be best to let the wikitext parsing take place and deactivate the genesis widget if it’s not a wikilink ?

The code would become

\define link(to)
<$let search={{{ [<__to__>minlength[3]]:map[all[tiddlers+shadows]search:title<__to__>] }}}>
<$genesis $type={{{ [<search>is[tiddler]then[$link]] }}} $names="to" $variables={{{ [<search>is[tiddler]] }}}>
<<__to__>>
</$genesis>
</$let>
\end

It still produce a span however, I don’t know if it’s a good behavior tbh

1 Like

Great,
The only problem here is you may have HelloThere and Hi HelloThere and HelloThere ii and it may return the wrong one!

1 Like

No, like you I do not know why we $genesis returns a span here

7 posts were split to a new topic: Issue with genesis-widget and missing parameter

That issue has been resolved: [IDEA] Empty type on the genesis widget shouldn't produce a span · Issue #7153 · Jermolene/TiddlyWiki5 · GitHub

1 Like