On Sun, 21 Mar 2021, Hans Hagen wrote: > On 3/20/2021 10:03 PM, Aditya Mahajan wrote: > > On Sat, 20 Mar 2021, Hans Hagen wrote: > > > > > > > > > > I wonder if we could have an environment, say \startluatemplate ... > > > > \stopluatemplate, which is evaluated on the fly rather than when loading > > > > a > > > > file. > > > > > > define 'evaluated on the fly' > > > > Consider the following example: > > > > \enablemode[A] > > \starttext > > \startluatemplate > > <?lua if tex.modes["A"] and not tex.modes["B"] then ?> > > \starttyping > > A and not B > > \stoptyping > > <?lua else ?> > > \starttyping > > not (A and not B) > > \stoptyping > > <?lua end ?> > > \stopluatemplate > > \stoptext > > > > What I am thinking is that \startluatemplate ... \stopluatemplate grabs the > > content (like a buffer) and then processes it using the mkix conversion > > mechanism. Thus, in terms of output, it should be equivalent to: > > > > \enablemode[A] > > \starttext > > \startbuffer[luatemplate] > > <?lua if tex.modes["A"] and not tex.modes["B"] then ?> > > \starttyping > > A and not B > > \stoptyping > > <?lua else ?> > > \starttyping > > not (A and not B) > > \stoptyping > > <?lua end ?> > > \stopbuffer > > \savebuffer[file={\jobname-luatemplate.mkix}, list={luatemplate}] > > \input \jobname-luatemplate.mkix > > \stoptext > > > > but without the need to save to an external file. > this is just for the mode right? in that case we can also can provide > > <?lua tex.enablemode("A") ?>
:-) I don't use templates too often, so I don't have other examples in mind where the \startluatemplate ... \stopluatemplate might be needed. So, just adding tex.enablemode at the lua will also work. We can see if another use case comes up in the future! Aditya ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________