dimanche 12 avril 2020

I am confused does the if else works differently in ejs

I want to know that what's wrong in this code i am trying to implement a login code and in here i want if there is a condition will be true than only show logout either show login or signup

                        <li><a href="/login">Login</a></li>
                        <li><a href="/register">Register</a></li>
                        <% } %>
                        <% else { %>
                        <li><a href="#">Signed In As : <%= currentUser.username %> </a></li>
                        <li><a href="/logout">Logout</a></li>
                        <%}%>

This is the wrong code i figured out that instead of giving a new line to else if i make it in a single line than the code runs but that's not the case with js only i want to know what is this means if i run this code than it works

                        <li><a href="/login">Login</a></li>
                        <li><a href="/register">Register</a></li>
                        <% } else { %>
                        <li><a href="#">Signed In As : <%= currentUser.username %> </a></li>
                        <li><a href="/logout">Logout</a></li>
                        <%}%>

Aucun commentaire:

Enregistrer un commentaire