{"id":73,"date":"2016-01-26T09:58:05","date_gmt":"2016-01-26T09:58:05","guid":{"rendered":"http:\/\/muthu.co\/?p=73"},"modified":"2021-01-02T14:06:04","modified_gmt":"2021-01-02T14:06:04","slug":"different-ways-of-rendering-a-variable-using-ejs","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/different-ways-of-rendering-a-variable-using-ejs\/","title":{"rendered":"Different ways of rendering a variable using EJS"},"content":{"rendered":"
The simplest way\u00a0of rendering a variable\u00a0is using the scriptlets, similar to the ones\u00a0used in JSPs<\/p>\n
<%= variable %><\/pre>\nBut if you want your code to be rendered or executed but not printed then render it like this:<\/p>\n
<% variable %><\/pre>\nIf you want your code to be evaluated as well as rendered (ex: variables containing HTML code) then use:<\/p>\n
<%- variable %> <!-- See the use of minus symbol within the scriptlets -->\r\n\r\n<\/pre>\nWe usually use the last method to render HTML on our EJS pages. <\/p>\n","protected":false},"excerpt":{"rendered":"
The simplest way\u00a0of rendering a variable\u00a0is using the scriptlets, similar to the ones\u00a0used in JSPs <%= variable %> But if you want your code to be rendered or executed but not printed then render it like this: <% variable %> If you want your code to be evaluated as well as rendered (ex: variables containing […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[64],"_links":{"self":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/73"}],"collection":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":1,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":1667,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/73\/revisions\/1667"}],"wp:attachment":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}