Creating Template Content

As noted in the controllers section of the tutorial, templates are, effectively, not much more than the original PHP files, which were a combination of PHP and HTML. However, they can also contain conditional logic, as you can see in the example below.

This template, in ownnotes/templates/part.content.php,contains the core form elements for creating notes. $l→t() is used to make your strings translatable and p() is used to print escaped HTML.

<script id="content-tpl" type="text/x-handlebars-template">
    {{#if note}}
        <div class="input"><textarea>{{ note.content }}</textarea></div>
        <div class="save"><button><?php p($l->t('Save')); ?></button></div>
    {{else}}
        <div class="input"><textarea disabled></textarea></div>
        <div class="save"><button disabled><?php p($l->t('Save')); ?></button></div>
    {{/if}}
</script>
<div id="editor"></div>