Can you store a WikiText table in a field?

Of course you can store a WikiText table in a field. But can you render it?
I only get one-lined tables rendered.

I am starting to discover the usefullness of fields and ViewTemplates.
Now I want to transfer existing Tiddlers. I want to copy my tables (written in WikiText) into fields and transclude them.
I know, I could transform them to html but is there way to use them in the WikiText-format in fields?

By tables you are refering specificaly wiki text tables using |

If so such tables need a new line for each row so the field needs to be a text area field. By default only the text field is a multiline field. If so we can help you with that.

  • if you do this you need to hide the field from the default field editor because it will remove the new lines

However a more common approach is to have the table in a seperate tiddler and transclude that, in block mode.

Personaly, except for basic and static tables, I make use of html tables because I can wrap rows and columns in a list widget and dynamically retrieve table content.

1 Like

Thanks!
Transcluding another table-tiddler sounds reasonable.

I hoped for a very easy solution…
That rabbit hole was not as deep as it looked and there is an easy solution.

I made a new FieldEditorFilters, got it in the right editor cascade and made my own field editor with an tag / type -attribute.

  • That’s curious can you illustrate this?

I cloned the default field editor and inserted type="textarea" in the <$edit-text tiddler... that makes my plan possible but tiddler in edit mode looks like a normal field. If I use tag="textarea" the field is multi-line. My Template filter is [suffix[-table]then[$:/_/fieldEditor/table]] and it is first in the cascade.

$:/_/fieldEditor/table:

<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> type="textarea" default="" class="tc-edit-texteditor tc-edit-fieldeditor" placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/>

While my solution looks good, the tiddler is “locked in” in the TiddlyWiki. If you import it to an empty.html the tables are lost. Only the first row is shown. So this ist not realy sustainlable.

It you have the table in a second Tiddler you have to remember to always share both Tiddlers.

Is there another way to

an preserve this setting when sharing the Tiddler?

If you can share the tiddlers involved perhaps we can add a little code in the main text field to transude the table field in the body, perhaps only when a particular condition is true, otherwise it’s easy to make a package of tiddlers that are easy to share between wikis.

At the moment I am playing with recipes.

Käsekuchen.json (1.5 KB)

This is how it looks at moment.

1 Like

hmmm. Now I’m hungry :slight_smile:

Just some comments about your wikitext. I would use a bit more spaces between your markup and text
eg:

!! Zutaten

Text below a heading

: Der Teig ...

* list 
** list 2

* list
** list 2 

and so on. IMO it improves readability of the plain text quite a bit and it does not make any difference to the rendered output.

Just a thought

-m

Bulleted Lists, numbered lists and definitions suffer from the same lack of line breaks in fields.

My plan was to have different ViewTemplates with different ordering and contents. I thought I could just “swirl” the translusions around in the ViewTemplate.