My directory structure goes like this:
Folder Dog
dog.html
template <name="dog">
dog.js
dog.css
I then further nest them.
This way, I have all the files I need (and often edit together) in one logical unit, which simplifies my navigation. Rarely, I have two templates per file, but that’s more of an exception and usually when the templates are “private”.
Is this a good practice?
The problem I have with it is, now I have a bunch of
if (Meteor.isClient) and if(Meteor.isServer).
That among other things means that my server code gets sent to the client, right? Not very good from security standpoint, even if it’s not executed on the client.
A more secure alternative I think would be to have a directory structure like this:
Folder Dog
dog.html
template <name="dog">
folder client
dogClient.js
dog.css
folder server
dogServer.js
However, that’s way too many folders for just 3 or 4 tiny files, an extra mouse click to expand and collapse them, and waste of IDE screen space if they are already expanded.
If my use case makes any sense at all, would it be logical to allow “client” and “server” in file names, not just in directory names? Or even something reserved, like $server, in order to account to files like “sendToServer.js”.
Am I making any sense? Or is my use case way off?
Edit: alternatively, how about parsing the .js files to make sure the if(Meteor.isServer)
clauses don’t get sent to the client?