fypp
fypp copied to clipboard
expanding macro in include directive
I wish to expand a macro in an include directive (to determine the file name). I have something like
#:set FILENAMES = ['file', 'anotherfile']
#:for FILE in FILENAMES
! some code
! now include a file
#:include "${FILE}$.fypp"
! more code
#:endfor
This does not work, and fypp
returns "include file '${FILE}$.fypp' not found"
. Is it possible to accomplish this? Thanks.
Indeed, currently that is not possible. Include events are handled during parsing, before any evaluation of variables or even conditionals. For example
#:if defined("INCLUDE_ME")
#:include "me"
#:endif
would always try to read the file me
, even if INCLUDE_ME
is not defined. But in that, case, the included content would not be evaluated.
In theory, one could change this behavior, but would need some coding, as the evaluation of the #:include
directive would have to be shifted.