<link rel="stylesheet" href="public/js/codemirror/lib/codemirror.css">
<script src="public/js/codemirror/lib/codemirror.js"></script>
<script src="public/js/codemirror/mode/javascript/javascript.js"></script>
<script src="public/js/codemirror/mode/xml/xml.js"></script>
<script src="public/js/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="public/js/codemirror/addon/edit/closebrackets.js"></script>
<script src="public/js/codemirror/addon/edit/closetag.js"></script>
{ifset $errors}
<div class="ink-alert basic error" role="alert">
  {reset( $errors )[0]}
</div>
{/ifset}
{import forms.html}
<form action="{$action}" method="POST" enctype="multipart/form-data" class="ink-form">
  <div class="control-group">
    <label for="template_name">{_'name'}</label>
    <div class="control">
      {include input, name => 'template[name]', value => ($model->name), maxlength => 100, required => true, autofocus => true}
    </div>
  </div>
  <div class="control-group">
    <label for="template_content_type">{_'media_type'}</label>
    <div class="control">
      {include input, name => 'template[content_type]', value => ($model->content_type), maxlength => 100, required => true, list => 'media_types'}
    </div>
  </div>
  <datalist id="media_types">
    <option value = "text/html">
  </datalist>
  <div class="control-group">
    <label for="template_content">{_'content'}</label>
    <div class="control">
      {include textarea, name => 'template[content]', cols => 40, rows => 60, value => ($model->content)}
    </div>
  </div>
  {include input, name => 'save', value => ( 'save'|translate ), 'type' => 'submit', class => 'ink-button green'}
  {include input, name => 'continue', value => ( 'save_and_continue'|translate ), 'type' => 'submit', class => 'ink-button green'} {_'or'} <a href="{=BASE_URL}template/list">{('cancel'|translate|lower)}</a>
</form>
<script>
 var editor = CodeMirror.fromTextArea(template_content, {
   lineNumbers: true,
   mode: "htmlmixed",
   autoCloseBrackets: true,
   autoCloseTags: true
 });
</script>
