Twig.js Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/twig.js/0.8.9/twig.js"></script>
<script type="text/twig" id="test">
    {% set tagname = "section" %}
    <{{ tagname}}>
    	content
    </{{ tagname }}
</script>

JavaScript

console.log(Twig);

$("script[type='text/twig']").each(function() {
    var id = $(this).attr("id"),
        data = $(this).text();
    
    twig({
        data: data,
        allowInlineIncludes: true
    }).renderAsync()
    .then(function (output) {
                 console.log(output)
      return output;

      
    })
});

$("body").append(
  
);