newenvironment with braces split between start and end

I'm defining a command for placing figures in the margin. A simple version follows:

\documentclass{article}
\newcommand{\margin}[1]{\marginpar{#1}}
\begin{document}
\margin{Figure goes here}
\end{document}


However, I'd like to make this command an environment, like so:

\documentclass{article}
\newenvironment{margin}{\marginpar{}{}}
\begin{document}
\begin{margin}
Figure goes here
\end{margin}
\end{document}


Here I'm naïvely using marginpar{ as my start code and } as my end code. But these braces end up getting paired with the braces used to delimit newenvironment's arguments, so I get an error.

How should I make this environment?

• See the environ package, it is made for gathering the contents of an env into a macro – daleif Oct 30 '15 at 19:03

You can use the environ package like this:
\documentclass{article}