Wordpress - Where to store PHP files created by plugin / themes
The appropriate place IMHO would be a custom folder that you create inside the wp-content directory Read this before creating files: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/
While working on a Wordpress plugin, I stumbled across your question. I also first thought about creating temporary files to cache some data my plugin was creating. However, giving it a bit more thinking, this approach seems odd to me as you don't want to have temporary data lying around on one server if you are trying to scale it using a cluster of servers.
So I searched again and it seems to valid solution for such problems is the Wordpress Transients API allowing you to store data in the database with an expiration date. Of course your problem could still require locally cached files, e.g. if they are too large for the database, but at least I suggest to take a look at this option, too :-)
You cannot rely on write access in the plugin or theme directory, so wp_upload_dir() is the only possible directory.
But I really doubt that there is a need to store the information in a new file. If the template is created by the user, store it in an option an parse the content with your regular plugin functions (for example by replacing placeholders with strtr()
).