ejs, how to add dynamic attributes of html tag?

Viewed 2287

I use express.js + ejs, I have two cases:

1.

<a href="<%= prevDisabledClass ? '' : ?page=<%=+page - 1%>%>">prev</a>

But it give me an error: Could not find matching close tag for "<%="./nundefined/nError: Could not find matching close tag for "<%=".

I want to get

prevDisabledClass ? <a href=''>prev</a> : <a href='?page=<%=+page - 1%>'>prev</a>

2.

like above, but dynamic add href attribute to html tag <a>

I want to get this:

prevDisabledClass ? <a>prev</a> : <a href='?page=<%=+page - 1%>'>prev</a>

How can I solve these two problem?

1 Answers
Related