javascripttemplatesicanhaz.js

ICanHaz.js just doesn't work


From ICanHaz example (slightly modified version of this: http://icanhazjs.com/):

The template:

<script id="user" type="text/html">
  <div>
    <p class="name">Hello I'm {{ name }}</p>
    <p><a href="http://twitter.com/{{ twitter }}">@{{ twitter }}</a></p>
  </div>
</script>

The code:

        var user_data, user;

        user_data = {
            name: "Henrik Joreteg",
            twitter: "HenrikJoreteg",
            employer: "&yet",
            job_title: "JS nerd"
        };

        user = ich.user(user_data, true);
        console.log(user.toString());

Console output is:

 <div>
        <p class="name">Hello I'm </p>
        <p><a href="http://twitter.com/">@</a></p>
 </div>

As you see it reads the template but it doesn't perform substitution. I don't know how to debug it, it's the simplest use case. I see no errors in the console.


Solution

  • As it turned out the problem was in tag collision between django framework I'm using and ICanHaz.js. The solution is to install django-icanhaz application which not only solves the problem but allows to store icanhaz.js templates as separate files.