Twig.js Playground

by justjohn

HTML

<script src="http://rc.foundryjs.com/twig/twig.js"></script>
<script type="text/twig" id="test">{{ app.id and (app.id) }}</script>

JavaScript

$("script[type='text/twig']").each(function() {
    var id = $(this).attr("id"),
        data = $(this).text();
    
    twig({
        id: id,
        data: data,
        debug: true,
        trace: true,
        allowInlineIncludes: true
    });
});

$("body").append(
    twig({ref: 'test'}).render({app: {id: 1}})
);