خرید بک لینک

Vote count: 0

I need to display formatted date using my underscore.js template. I am using moment.js. My template is as follows:

// date, homeTeamName, homeTeamName values come from JSON object

<script type="text/template" id="fixtureTemplate">

    <% var matchDay = moment( %> + <%= date %> + <%); %>
    <h5> <% matchDay.format("MMMM-DD-YYYY"); %> </h5>

    <h5 class="red"><%= homeTeamName %> : <%= homeTeamName %></h5>

</script>

This does not render the template properly. Gives an error:

underscore.js:1454 Uncaught SyntaxError: missing ) after argument list

which is somewhere deep in underscore.js.

What's the proper syntax to put a JSON value inside code in the template, i.e. how can I pass date, which comes from JSON object; into moment()

The code which I want to generate in template looks like this:

var matchDay = moment("2016-05-15T15:00:00Z"); // date should fill from JSON value
matchDay.format("MMMM-DD-YYYY");

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 21 فروردين 1395 ساعت: 5:00

صفحه بندی