How to create a new tiddler tagged with tab name?

Hello,

I’m looking for a solution to get the current open TAB name to create a new tiddler tagged with it.

I don’t know if i am very clear :wink: so i join a picture of my issue and the code of my two tiddlers.

My first approach was to use the contents of the tab’s “state” tiddler (which contains the name of the open tab) but this doesn’t work.
I think the syntax is wrong.
Do you have any advice on how to achieve this?

Thank you.

Home 1

<$reveal type='match' state='StateAddBookmarkL1' text='show' >

<$transclude
        tiddler='Add Bookmark L1'
    />
</$reveal>

 <$button class="tc-btn-invisible" set='StateAddBookmarkL1' setTo='show' >
       ,,{{$:/core/images/new-button}} cat L1,,
    </$button>

<$macrocall $name="tabs" tabsList="[tag[L1]sort[]]" state="$:/temp/state/tab"/>

AA

    Name:
    <$edit-text tiddler='tempNewBookmarkL2' field=name class='tc-edit-texteditor'  />

    <$button set='StateAddBookmarkL2'  setTo='hide' >Add L2
        <$action-setfield
            $tiddler='tempNewBookmarkL2'
            $field='title'
            $value={{tempNewBookmarkL2!!name}}
        />

     <$fieldmangler tiddler={{tempNewBookmarkL2!!name}} >
            <$action-sendmessage $message='tm-add-tag' $param={{$:/temp/state/tab}} />
        </$fieldmangler>
        <$action-setfield $tiddler='tempNewBookmarkL2' name='' />
    </$button>

Inside tabs the variable <<currentTab>> contains the tab tiddler. See tabs Macro

1 Like

Thank you for this usefull info.

In the “AA” tiddler, when i change this:

to:

 <$action-sendmessage $message='tm-add-tag' $param=<<currentTab>> />

The new tiddler created includes the desired tag (AA), but it is also contaminated with other irrelevant tags, and I don’t understand why…

How can I debug or view the content of the <<currentTab>> variable ?

Whenever you see weird stuff like that, it’s an indication you have “broken” HTML or wikitext syntax somewhere in your code.

Look for

  • a missing > (unclosed element, macro call, $let, $set etc)
  • a missing \end (unclosed macro/proc/function definition)
  • poorly matched quotes

That last one can cause havoc depending on the position of the culprit. One that happens to me fairly frequently (thanks to codemirror) looks like this:

""stuff and things"

or

"stuff and things""
1 Like
<$log $$message="my-message" currentTab=<<currentTab>> />

https://tiddlywiki.com/#LogWidget
https://tiddlywiki.com/#ActionLogWidget

You’re right.
I started again from an empty tiddlywiki file and everything is fine now.

Thank you, I didn’t know, it’s very interesting !