twig.js: Twig is not defined ? Browser

Hello, when I try this code in teh Browser I get ‘twig is not defined’ ?

<script src="../twig.js"></script>
<script>
var template = twig({
    id: "list", // id is optional, but useful for referencing the template later
    data: "{% for value in list %}{{ value }}, {% endfor %}"
});

var output = template.render({
    list: ["one", "two", "three"]
});
</script>

what is missing?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15

Most upvoted comments

I encountered the same issue when running v1.12.0 in the browser, with the same example code from the original post. For me the fix was replacing:

var template = twig(...)

with:

var template = Twig.twig(...)