![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 8/2/2021 4:43 PM, Aditya Mahajan via ntg-context wrote:
On Mon, 2 Aug 2021, Benjamin Buchmuller via ntg-context wrote:
Hi,
How can I check if a buffer or block has content (or is empty) before a \useblocks or \getbuffer statement?
I would like to typeset a headline only if the buffer/block has been used in a particular section and want to avoid headlines with empty sections.
There may be more efficient ways to do it (since buffers are stored at the lua end), but you can always do \doiftextelse(\getbuffer[...]} to test it buffer creates any output. indeed you know there is a way ...
\starttext \startbuffer[test] test \stopbuffer \doifelsebuffer{test} {YES} {NOP} \permanent\protected\def\doifelsebuffercontent#1% {\doifelse{\luaexpr{(string.strip(buffers.getcontent("#1")) ~= "" and "yes")}}{yes}} \startbuffer[test] \stopbuffer \doifelsebuffercontent{test} {YES} {NOP} \startbuffer[test] \stopbuffer \doifelsebuffercontent{test} {YES} {NOP} \stoptext if we can agree on a proper name then i can add a (more efficient) \doifelse... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------