{% if user -%}
<script>
    console.log("current user is {{ user.username }}");
</script>
{%- endif %}