Mám výhled složky strukturu a EJS souborů profile_60113.ejs takhle
views
docs
profile_60113.ejs
Mohu dynamicky vykreslit soubor takhle (kde data.groupID == 60113):
<%- include(docs/profile_ + data.groupID); %>
Ale jak mohu nejprve zkontrolovat, zda soubor existuje? Zkoušel jsem to:
<% if (fs.existsSync(views/docs/profile_ + data.groupID)) { %>
<%- include(docs/profile_ + data.groupID); %>
<% } %>
Nebo ...
<% if (fs.existsSync(docs/profile_ + data.groupID)) { %>
<%- include(docs/profile_ + data.groupID); %>
<% } %>
Ale nefungoval ... const fs = require ( ‚fs‘) je zahrnuta v řídicí jednotce a FS: fs je vykreslen