You have to expand \BODY
before \begin{mytaskenum}
starts its job:
\documentclass[a4paper]{book}
\usepackage{environ}
\usepackage[more]{tasks}
\NewTasks[style=enumerate,counter-format=tsk[1]),label-width=2ex]{mytaskenum}[\item](3)
\NewEnviron{mytaskenv}[1][Exercises]{%
% Misc. stuff to preceed the tasks env here
\def\tempbegin{\begin{mytaskenum}}%
\expandafter\tempbegin\BODY
\end{mytaskenum}
% Misc. stuff to follow
}
\begin{document}
\begin{mytaskenv}
\item item 1
\item item 2
\item item 3
\end{mytaskenv}
Check:
\begin{mytaskenum}
\item item 1
\item item 2
\item item 3
\end{mytaskenum}
\end{document}

Cleaner alternative with xparse
:
\documentclass[a4paper]{book}
\usepackage{environ}
\usepackage[more]{tasks}
\usepackage{xparse}
\NewTasks[style=enumerate,counter-format=tsk[1]),label-width=2ex]{mytaskenum}[\item](3)
\ExplSyntaxOn
\NewDocumentCommand{\domytaskenum}{}
{
\texman_mytaskenum:V \BODY
}
\cs_new_protected:Npn \texman_mytaskenum:n #1
{
\begin{mytaskenum}
#1
\end{mytaskenum}
}
\cs_generate_variant:Nn \texman_mytaskenum:n { V }
\ExplSyntaxOff
\NewEnviron{mytaskenv}[1][Exercises]{%
% Misc. stuff to preceed the tasks env here
\domytaskenum
% Misc. stuff to follow
}
\begin{document}
\begin{mytaskenv}
\item item 1
\item item 2
\item item 3
\end{mytaskenv}
Check:
\begin{mytaskenum}
\item item 1
\item item 2
\item item 3
\end{mytaskenum}
\end{document}
The \domytaskenum
command simply calls \texman_domytaskenum:V \BODY
; in turn \texman_domytaskenum:V
is a variant of \texman_domytaskenum:n
that does the job of processing the argument in the mytaskenum
environment. The V
variant uses the value of the token list stored in \BODY
as if it was the explicit contents. Basically it does the same trick as before, but in a more abstract way, without doing the temporary definition.
\BODY
is provided byenviron
; it expands to the contents of what's between\begin{mytaskenv}
and\end{mytaskenv}
. Perhaps I'm misunderstanding your suggestion?tasks
needs to see the expansion of the macro\BODY
in order to do its work