Adding Prefixes/suffixes to a block transclusion

73 views
Skip to first unread message

Reece Shaw

unread,
Mar 7, 2020, 10:31:06 PM3/7/20
to TiddlyWiki
Hello all,

Currently I am using transclusions in block mode to create some text blocks from a data tiddler. Ideally, to display the data from said data tiddler, I would like to add a prefix to the rendered text that appears in line with the text from the field.

Problem is that if I include text outside of the transclusion, it will render above the text. I was testing with the below macro in a tiddler that has the field "test".


\define pff-display-xblock(field:"" prefix:"")
<$list filter='[is[current]has[$field$]]'>
$prefix$<$transclude field="$field$" mode="block" />
</$list>
\end

<<pff-display-xblock "test" "prefix">>

I can't use the inline mode because the fields may have text such as ordered lists, which do not render correctly in inline mode. Any thoughts on how to render this without the line break?

Included a screenshot to show the rendered text.

-Reece
prefixtest.PNG

Jeremy Ruston

unread,
Mar 8, 2020, 1:37:32 PM3/8/20
to TiddlyWiki
Hi Reece

It may be worth trying to use CSS float: left to position the prefix?

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6a943130-ccb4-4d24-ad07-017c8688a5b6%40googlegroups.com.
<prefixtest.PNG>

Mat

unread,
Mar 8, 2020, 2:09:05 PM3/8/20
to TiddlyWiki
Jeremy Ruston wrote:
It may be worth trying to use CSS float: left to position the prefix?

...and he'd have to move the transclusion to the right also, I'd think.
This, and Reeces other similar "block issues" caused from transclusion blockmode, are interesting. Maybe the transclusionwidget should have a class attribute?


Reece, here's an alternative solution that might work IF you prefix is a string that fulfills common css definition name rules.

\define pff-display-xblock(field:"" class:"")

<$list filter='[is[current]has[$field$]]'>
<div class="myclass $class$">
<$transclude field="$field$" mode="block" /></div>
</$list>
\end

<<pff-display-xblock "caption" "xxx">>

<style>
.myclass { margin-left:2em;}
.xxx::before {content:"xxx"; position:absolute; margin-left:-2em}
</
style>

The prefix you use in the macrocall (i.e "xxx") has a corresponding styledefinition (i.e ".xxx").

<:-)

Jeremy Ruston

unread,
Mar 8, 2020, 2:12:24 PM3/8/20
to TiddlyWiki
Hi Mat
This, and Reeces other similar "block issues" caused from transclusion blockmode, are interesting. Maybe the transclusionwidget should have a class attribute?

The transclude widget doesn’t generate any DOM elements itself, and so there would be nowhere to attach the class.

But this is more of an HTML issue, I think: there’s no facility for injecting content into a block other than float, as far as I know.

Best wishes

Jeremy.



Reece, here's an alternative solution that might work IF you prefix is a string that fulfills common css definition name rules.

\define pff-display-xblock(field:"" class:"")
<$list filter='[is[current]has[$field$]]'>
<div class="myclass $class$">
<$transclude field="$field$" mode="block" /></div>
</$list>
\end

<<pff-display-xblock "caption" "xxx">>

<style>
.myclass { margin-left:2em;}
.xxx::before {content:"xxx"; position:absolute; margin-left:-2em}
</
style>

The prefix you use in the macrocall (i.e "xxx") has a corresponding styledefinition (i.e ".xxx").

<:-)

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Reece Shaw

unread,
Mar 8, 2020, 9:42:12 PM3/8/20
to TiddlyWiki
Floating the prefix left seems to do the trick, it even wraps the block text around the float which is visually appealing for these purposes.

I run up against a lot of CSS/HTML issues because of my wiki structure. I imagine being able to apply a class to a transclusion would be helpful for some of these problems, as previous forays with classes have caused  me headaches.

Thanks!

-Reece


On Sunday, March 8, 2020 at 2:12:24 PM UTC-4, Jeremy Ruston wrote:
Hi Mat
This, and Reeces other similar "block issues" caused from transclusion blockmode, are interesting. Maybe the transclusionwidget should have a class attribute?

The transclude widget doesn’t generate any DOM elements itself, and so there would be nowhere to attach the class.

 
But this is more of an HTML issue, I think: there’s no facility for injecting content into a block other than float, as far as I know.

Best wishes

Jeremy.



Reece, here's an alternative solution that might work IF you prefix is a string that fulfills common css definition name rules.

\define pff-display-xblock(field:"" class:"")
<$list filter='[is[current]has[$field$]]'>
<div class="myclass $class$">
<$transclude field="$field$" mode="block" /></div>
</$list>
\end

<<pff-display-xblock "caption" "xxx">>

<style>
.myclass { margin-left:2em;}
.xxx::before {content:"xxx"; position:absolute; margin-left:-2em}
</
style>

The prefix you use in the macrocall (i.e "xxx") has a corresponding styledefinition (i.e ".xxx").

<:-)

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages