Access arbitrary attribute=value pair?

Folks,

It is possible to add arbitrary attributes (and tags) in html such as on a html <a record we may add browser={{$:/info/browser/name}} or browser=Firefox.

  • I understand we can use this to target CSS
  • perhaps we can parse the html as text to extract prefix[browser=] getting browser=Firefox or browser="Firefox"

Or is there another way we could access a value of a named attribute to set a tiddlywiki variable, or make use of it?

Why;

  • I am working on an alternative link capture to the permalink to support the use of multiple wikis and it would be nice to include a browser attribute so I know in which browser to use it.
  • I expect there could be other uses for this, to slip attribute=value pairs into html that tiddlywiki can make use of.

Storing state information in the DOM and reading it from there does not make much sense in TW. We do have the let-widget and \define atm. \define is a shortcut for a set-widget with a scope of the tiddler which contains the definition. IMO you should use existing mechanisms that work out of the box already.

Wikitext should not be browser specific. Everytime we do have browser specific conditions in the core they cause problems in the long run.

Thanks @pmario but this html content will come from somewhere else and along with a href, display name and target, I want to embed the browser name to test if they destination is used in this browser or not.

I use one browser for tiddlywiki design and one for general use.

Basicaly its about parsing a html snipit and extracting a attribute value pairs. I can restrict it to string=string.

However I am asking a more general question to see if it can facilitate more general solitions.

Prefixing the attributes with data-* is the standard way of doing this:

Such attributes can be accessed using CSS.

2 Likes

As well as via the eventcatcher widget.

2 Likes