Tiddler Field: Naming Rule - Is This a Bug?

TiddlyWiki allows you to create a field with upper/lower case and even number other unicode characters, spaces, etc.

Then in official docs, https://tiddlywiki.com/#Introduction%20to%20filter%20notation

One can use filter expressions like [serving[3]] or [myFieldName[yes]].

Then what if the name of the field was: this is A Field - Name. Can I use again:

[ this is A Field - Name [3]] or [ this is A Field - Name [yes]].

Is the recommendation to stick with lowercase no space no ± chars naming rule?

Not a bug, but you’re right; I’m not an expert on the matter but I’d say; do excercize some care when naming fields if you are going to use them for more than plain text references. Don’t user spaces or special characters like brackets, pipe chars, quotes…

A technique to scrub arbitrary strings to make them safer as fields is to run the slugify filter op on them.

The convention you use here is [operator-name[parameter]] … Since serving is no official operator, the parser assumes, that it is a field. So your example is a shortcut for [field:serving[3]]

  • The filter-run for field operator is
    • [field:field-name[parameter]]
  • So if you have a field with spaces you need to use
    • [field:this is a field name[something]]

But I personally would never do this. Especially “leading” and “trailing” spaces will “break your neck” in the future.

I stick to name-with-hyphens or camelCaseNames depending on the usecase. IMO you should stick with 1 system, because it’s easier to remember.

At tiddlywiki-com we use name-with-hyphens and we have no problems with that.

4 Likes

I second @pmario’s advice and will add that in a field name, you should avoid any character which has a meaning in regexps, including forward slashes (/).

I got a lot of troubles with this in an avoided experiment on “fields namespaces”. My idea was to name “system fields” like system tiddlers, using a $:/ prefix. Don’t do it as it has all kind of nasty side-effects.

Fred

Thank you all for your fruitful inputs.

Based on your comments: I think lowercase with the kebab-case naming is the way I will go! (like this-is-a-field-name).

I do not like [field:this is A Field - Name [yes]] as it is quite confusing!