javascript - Unable to include dynamically created file within include statement using node.js, express and embedjs -


i trying include html file, whether .ejs or .html, in dynamically manner.

so instance, in extremely simple case, want call file either says either, ./views/nextdirectory/loggedin.ejs

<div class="loggedin">hi <%= user.name %></div> 

or ./views/nextdirextory/loggedout.ejs

<ul class="nav">   <li><a href="login">log in</a></li>   <li><a href="signup">sign up</a></li> </ul> 

--

in web.js file, check if user logged in , set variable called loggedinornot holds either ./nextdirectory/loggedin.ejs or ./nextdirectory/loggedout.ejs , call loggedinornot in page.ejs file.

i know can use include statement shown here however, unable use dynamically created variable include statement.

update:
answer here. didn't see before posting question, although think more of hack or fix appropriate application. not sure how may work application extends:
using interpolation within node.js ejs includes

update:
doesn't work. html markup shows , not rendered.

update:
got work. simple mistake. had add hyphen shown below:

<%- loggedinornot %> 


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -