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. 

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
___________________________________________________________________________________

Reply via email to