MommaWatasu / OteraEngine.jl

This package is a template engine for Julia Lang.
https://mommawatasu.github.io/OteraEngine.jl/stable
MIT License
20 stars 4 forks source link

Template render failing #26

Closed Justyn-Nissly closed 7 months ago

Justyn-Nissly commented 7 months ago

While learning how to use OteraEngine with Oxygen.jl I got an error when trying to render a template.

The error: UndefVarError: thtow not defined

The fix: I was able to resolve this issue by changing thtow to throw line 139 in src/template.jl

The template used:

<table>
        <thead>
            <tr>
                <th>First</th><th>Last</th><th>Phone</th><th>Email</th><th></th>
            </tr>
        </thead>
        <tbody>
            {% for i in contacts %}
            <tr>
                <td>{{ i["first"] }}</td>
                <td>{{ i["last"] }}</td>
                <td>{{ i["phone"] }}</td>
                <td>{{ i["email"] }}</td>
                <td>
                    <div id="contact-menu-{{ i["id"] }}">
                        <a href="/contacts/{{ i["id"] }}/edit">Edit</a>
                        <a href="/contacts/{{ i["id"] }}">View</a>
                    </div>
                </td>
            </tr>
            {% end %}
        </tbody>
    </table>

Data sent:

test_dict = Dict(
    "contacts" => [
        Dict(
            "id" => 1,
            "first" => "John",
            "last" => "Doe",
            "phone" => "555-1234",
            "email" => "john.doe@example.com"
        ),
        Dict(
            "id" => 2,
            "first" => "Jane",
            "last" => "Doe",
            "phone" => "555-1234",
            "email" => "jane.doe@example.com"
        ),
        Dict(
            "id" => 3,
            "first" => "Josh",
            "last" => "Doe",
            "phone" => "555-1234",
            "email" => "josh.doe@example.com"
        )
    ]
)

p.s. Great work on the package. I have greatly enjoyed using it.

MommaWatasu commented 7 months ago

Hi @Justyn-Nissly .

Thanks for your report. I fixed it and released new version v0.4.2.