Search code examples
node.jssails.jsejsembedded-javascript

Multiple variables declaration in ejs


I am trying to declare and assign a default value to multiple variables. But the value is only getting assigned to last variable

<% var scale_text,scale_image = 'free_transform'; %>

This print empty:

<%- scale_text %>

This prints free_transform

<%- scale_image %>

What am i missing?


Solution

  • Separate the variables with = to set them to the same default value.

    <% var scale_text, scale_image; %>
    <% scale_text = scale_image = 'free_transform'; %>