Meaning of にと思って in a sentence


I've been thinking about this for a few days but I still can't figure out what
this means. Sorry if this is really beginner-like!

I was wondering what this particular part in a sentence means: にと思って. Example
sentence is:

> ［これは私の新しいレシピだ。］君のお弁当 **にと思って** 作ってきたんだ。

(the first sentence is only there for context, the second contains what I want
to ask for.)

Please help! I appreciate any answers.




I assume you know how to use ～と思って, which is "..., thinking ～". Try to read it
like this:

> 「君のお弁当に」と思って作ってきたんだ。

Everything before the quotative-と is a quote (in this context, what he
thought). So 君のお弁当に is the content of his thoughts, and it makes sense on its
own. The particle に has many functions, one of which is denoting a purpose.
It's like English "as ～" or "for ～".

>   * プレゼントに人形を買いました。 I bought a doll as a present.
>   * 何に使うの？ What do you use it for? / What is it for?
>

Thus the sentence means simply "I made it for/as your _bento_ /lunch.", or
more literally, "I made it thinking '(It would be) for your _bento_.'"

