Skip to content

Instantly share code, notes, and snippets.

@jumbojet
Created February 7, 2015 16:02
Show Gist options
  • Save jumbojet/77418851af2e3be18921 to your computer and use it in GitHub Desktop.
Save jumbojet/77418851af2e3be18921 to your computer and use it in GitHub Desktop.
Conditional Execution
<script>
// Lets think template_variable is a django template variable
var is_condtion = {% if template_variable %}true{% else %}false{% endif %};
if (is_condtion == false)
{
alert("Execute this code if is_condition is true");
// For example
<div> Hello How are you </div>
}
else
{
alert("Execute this code if is_condition is false");
$("#divTest").html("Hello World");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment