How do I add quotation marks around a transcluded field?

What am I missing here?

<$list filter="[<currentTiddler>fields[][caption]]" variable="thisfield">
  <$transclude field={{{ [<currentTiddler>get<thisfield>addprefix[&quot;]addsuffix[&quot;]] }}}/>
</$list>

You have a couple of syntax errors, and you don’t need the $transclude widget if you are simply using the triple-brace “filtered translcusion” for text-manipulation. You can use it on its own.

<$list filter="[<currentTiddler>fields[]]" variable="thisfield">
  {{{ [<currentTiddler>get<thisfield>addprefix[&quot;]addsuffix[&quot;]] }}}
</$list>

That will try to “linkify” the results of the filtered-transclusion, and you can “force it back to plain text” like this:

<$list filter="[<currentTiddler>fields[]]" variable="thisfield">
  <$text text={{{ [<currentTiddler>get<thisfield>addprefix[&quot;]addsuffix[&quot;]] }}}/>
</$list>

How do I get it from a specific field?

Nevermind, I was making it more complicated than it was:

 <$text text={{{ [{!!field-name}addprefix["]addsuffix["]] }}}/>

This did the trick. However, I had to change to actual quotation marks. Thanks for the help.

But, I also needed it transcluded because the output will sometimes include HTML tags.

@RedAsset it all depends on how you want to use the result;

To display it quoted
“<$text text={{!!field-name}}/>”

and many other forms.

With that, the quotation marks would always be present even if the field is not present.

I needed to determine if the field exists first, like this:

<$list filter="[<currentTiddler>has:field[field-name]]">
 "<$transclude field="field-name"/>"
</$list>

I did not know how to do this earlier when I asked the question.

Thanks, anyway.

Here are some other ways to address your question; illustrating there are more than one and having different use cases.

This form will get the fieldname value if it contains a value otherwise nothing.

<$list filter="[<currentTiddler>get[field-name]]">
 "<$text text=<<currentTiddler>>/>"
</$list>

But returning to your previous form, the following match your requirements;

<$text text={{{ [all[current]get[field-name]] +[addprefix["]addsuffix["]] }}}/>

Or
<$text text={{{ [all[current]get[field-name]addprefix["]addsuffix["]] }}}/>

You could also have a missing output
<$text text={{{ [all[current]get[field-name]addprefix["]addsuffix["]else[empty]] }}}/>

In the above 3 cases, the prefix and suffix is only used if get[field-name] returns a value.

However if the intention was to indicate when empty you could

"<$view field="field-name"/>"
or
field-name: "<$view field="field-name"/>"
or
field-name: "<$view field="field-name">empty</$view>"

In the above 3 cases, View Widget can be used rather than the less tidy textWidget

  • The viewWidgets default output is Plain text
  • In the last case the contents of the view Widget is displayed if the result is empty.