<script>
    window.fbAsyncInit = function() {
        FB.init({appId: {{ app_id }}, status: true, cookie: true, xfbml: true});    
        {{ code|safe }}
    }
</script>

<div id="fb-root"></div>
<script>
    (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
            '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
