saqimtiaz / streams

TiddlyWiki plugin for rapid data entry with a keyboard driven workflow. Divide content into smaller tiddlers as you write.
BSD 3-Clause "New" or "Revised" License
58 stars 6 forks source link

Expose tiddler tags when rendering stream-row #15

Closed zhangxiubo closed 3 years ago

zhangxiubo commented 3 years ago

For each stream-row, expose the tags associated with its corresponding tiddler in an attribute called "data-node-tags".

Multiple tags are separated with ";".

This makes it easier to style the nodes based on tags on the tiddlers.

saqimtiaz commented 3 years ago

@zhangxiubo I've been meaning to add this for a while. However, I was thinking to do it the way the TiddlyWiki core adds the data-tags attribute using {{!!tags}}

See: https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/ViewTemplate.tid#L8 Then we can do custom styling by tag as documented at: https://tiddlywiki.com/#Custom%20styles%20by%20data-tags

What do you think?

zhangxiubo commented 3 years ago

Yes that's what I wanted to do with this --- styling each row based on the node's data-node-tags attribute. I intentionally avoided using data-tags to allow the styling to be more specific (e.g. only highlight rows in the outliner, not the actual tiddler card). Since we already use data-node-title, I feel it would be consistent to follow the naming convention, hence data-node-tags

{{!!tags}} was what I tried originally to populate the attribute but it didn't work --- the attribute appeared empty when rendered as HTML. I am quite new to Tiddlywiki development so I must have missed something.

saqimtiaz commented 3 years ago

I have implemented this in https://github.com/saqimtiaz/streams/commit/b5e10358b679b15251487ce7acb65d31db4fef64

Let me know if you have any issues with it. Thank you.