The genesis widget : "real-life" examples

This post is a wiki, it can be edited by everyone logged in.

To help users understand how to use the genesis widget, please add real examples here!

See also Questions about the genesis widget


Generate html elements with booleans attributes

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. The $names attribute of the genesis widget can be used to toggle boolean attributes.

Youtube iframe with fullscreen toggled by a filter

Toggle on or off the allowfullscreen attribute on a youtube iframe:

<$checkbox field="fullscreen-is-allowed" checked="allowfullscreen"> 
Allow fullscreen?
</$checkbox>

<$genesis
$type="iframe" 
$names="[{!!fullscreen-is-allowed}match[allowfullscreen]]" $values="[[]]"
width="560" 
height="315" 
src="https://www.youtube.com/embed/videoseries?list=PLzZCajspPU_UjFn0uy-J9URz0LP4zhxRK" 
title="YouTube video player" 
frameborder="0" 
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" 
/>

Switch between widgets and html element

The $type attribute of the genesis widget is useful to conditionally set the type of the element generated (widget or html ?).

Internal or external link based on search

\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

Assigns values to variables with filters

The genesis widget can act as a substitute for the setmultiplevariables widget:

<$setmultiplevariables $names="var1 var2" $values="[[value 1]] [[value 2]]">

* var1 = <<var1>>
* var2 = <<var2>>

</$setmultiplevariables>

Is equivalent to

<$genesis $type="$let" $names="var1 var2" $values="[[value 1]] [[value 2]]">

* var1 = <<var1>>
* var2 = <<var2>>

</$genesis>
3 Likes

Closed (locked), but you can still edit the wiki. See thread Questions about the genesis widget for discussion.

1 Like