I'm creating a style file, and want to store the body text of the abstract environment so that I can put it on my custom titlepage. I could have required that my users enter the abstract as
\customabstract{Abstract text goes here}`
which I would have implemented as something like
\newcommand{\customabstract}[1]{\gdef\abstracttext{#1}}
However, I would prefer that the user is able to use environment notation,
\begin{customabstract}Abstract text goes here\end{customabstract}
To do this, I thought I could define something like
\newenvironment{customabstract}{\gdef\abstracttext\bgroup}{\egroup}
But this definition makes \abstracttext expand to \bgroup, which is not what I wanted. I tried to solve the problem by \expandafter,
\newenvironment{customabstract}{\expandafter\gdef\expandafter\abstracttext\bgroup}{\egroup}
but this results in a runaway error.
Is there any way to acheive what I want? Answers that helps me understand the inner workings of TeX (instead of just referring to a custom package) are preferred.