Skip to content

Commit

Permalink
Add markdown editor macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancyam committed May 14, 2017
1 parent bc430d0 commit d3ad250
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions nyaa/templates/_formhelpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@
</div>
{% endmacro %}


{% macro render_markdown_editor(field, field_name='') %}
{% if field.errors %}
<div class="form-group has-error">
{% else %}
<div class="form-group">
{% endif %}
<div class="markdown-editor" id="{{ field_name }}-markdown-editor">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#{{ field_name }}-tab" aria-controls="" role="tab" data-toggle="tab">Write</a></li>
<li role="presentation"><a href="#{{ field_name }}-preview" id="{{ field_name }}-preview-tab" aria-controls="preview" role="tab" data-toggle="tab">Preview</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="{{ field_name }}-tab" data-markdown-target="#{{ field_name }}-markdown-target">
{{ render_field(field, class_='form-control markdown-source') }}
</div>
<div role="tabpanel" class="tab-pane" id="{{ field_name }}-preview">
<div id="{{ field_name }}-markdown-target"></div>
</div>
</div>
</div>
{% endmacro %}


{% macro render_upload(field) %}
{% if field.errors %}
<div class="form-group has-error">
Expand Down
1 change: 1 addition & 0 deletions nyaa/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block body %}
{% from "_formhelpers.html" import render_field %}
{% from "_formhelpers.html" import render_upload %}
{% from "_formhelpers.html" import render_markdown_editor %}

<h1>Upload Torrent</h1>

Expand Down

0 comments on commit d3ad250

Please sign in to comment.