How to use if else statements in underscore.js template ?

There is always a need to have a condition check when populating your underscore.js tempalte. For instance in my case I had a model and few fields in the model had null values so when they were rendered with these values, I got an output like the one shown below :

This clearly isn’t right, instead what should have happened here was, whenever the data in model was ‘null’ the text box should have been left empty. So here is how this is done in underscore.js template :

<div class="editor-label">
  <label>First Name : </label>
</div>

<div class="editor-field">
    <% if(FirstName == null) { %>
        <input type="text" id="txtFirstName" value="" />
    <% } else { %>
        <input type="text" id="txtFirstName" value="<%=FirstName%>" />
    <% } %>
</div>

Further Reading

Why Windows 8 Phone development sucks !

Earlier this month, I had started with my first Windows 8 Phone app development : Interview QA. This post is a summary of my experience with Windows 8 Phone development.

HURDLE 1 : Windows 8 and Visual Studio 2012 : In order to develop for Windows Phone 8 you need Windows 8 64-bits and Visual Studio 2012, you CANNOT develop a windows phone app without these. Windows 8 64 bit upgrade costs around 2200 INR in India, However the express edition of Visual Studio 2012 was free and can be downloaded from here. HURDLE 2 : Jquery Mobile support : On the jquerymobile’s official website(as shown below), support for Windows Phone was mentioned.

However on completion of my app when I tested my app on Windows Phone emulator I ran into loads of problem, documented here and here, and believe it or not here’s the best answer I got on one of my questions posted on stackoverflow.


Seriously ?

HURDLE 3 : STORE REGISTRATION FEE : 4,500 INR annually !!! No matter what app you are making, be it paid, open source or whatever you need to pay an annual fee to get a windows 8 phone store license. Just not cool.

How to embed Youtube videos in WP Markdown Editor ?

I have been using this awesome WordPress plugin called WP-Markdown for over a year on this blog. So today again I came across this neatly explained tutorial on “Javascript Closures” by Mark Dalgleish which I decided to add as a post on my blog, but the default youtube embed code just wont work.

 So after reading a little bit, I found this question asked 

here and the solution was to used the embed tags. Solution : Hope this helps :)

How to check the created date and last modified date of a stored procedure in SQL ?

One often has a need to check the last modified date or the created date of a stored procedure in SQL. So, below is an SQL script that allows you to view the stored procedure name, created date and last modified date of the stored procedure.

USE DatabaseName; 
GO SELECT name, create_date, modify_date 
FROM sys.objects 
WHERE type = 'P' AND name = 'StoredProcedureName'
GO

Hope this helps :)