<!DOCTYPE html>
<html>
    <head>
        <title>Template Editor</title>
    </head>

    <body>
        <form>
            <select id='template_id' name='template_id' onchange="retrieveTemplate('template_id','template_value')">
                <option value='0'>-- Templates --</option>
                {% for t in app.user.templates %}
                <option value='{{ t.id }}'>{{ t.name }}</option>
                {% endfor %}
            </select>&nbsp;&nbsp;
            <input type='text' name='name' id='template_name' />&nbsp;&nbsp;
            <input type='button' name='submit' value='Save' onclick='saveTemplate()' />&nbsp;&nbsp;
            <a href='/home'>Back</a>
            <br />

            <textarea id='template_value' name='template' wrap='hard' cols=100 rows=45></textarea>
        </form>

        <script type='module'>
            import * as state from "{{ asset('js/state.js') }}";
            import {retrieveTemplate, saveTemplate} from "{{ asset('js/template.js') }}";
            window.retrieveTemplate = retrieveTemplate;
            window.saveTemplate = saveTemplate;
        </script>
    </body>
</html>