squirrellyjs / squirrelly

Semi-embedded JS template engine that supports helpers, filters, partials, and template inheritance. 4KB minzipped, written in TypeScript ⛺
https://squirrelly.js.org
MIT License
555 stars 81 forks source link

Conditions Doesn't Seem To Work #230

Closed wombatastronaut closed 2 years ago

wombatastronaut commented 2 years ago

I'm trying to use the condition inside the template but it's not working as expected.

Here's my full code:

    <div id="template" role="template">
        Name: {{ options.name }} <br />

        {{if(options.name == 'John Doe')}}
            You're right
        {{#else}}
            You're not right
        {{/if}}
    </div>

    <div id="content"></div>

    <script src="https://cdn.jsdelivr.net/npm/squirrelly@7/dist/squirrelly.min.js"></script>
    <script>
        var template = document.getElementById('template').innerHTML;
        var content = document.getElementById('content');

        var result = Sqrl.Render(template, {
            options: {
                name: 'John Doe'
            }
        });

        content.innerHTML = result;
    </script>

But here's the result: image

You can see that it didn't go to the if condition even though its true. I also render the name above and it has the correct value.