Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Last active January 19, 2016 17:45
Show Gist options
  • Save nietzscheson/36a14e4fe821cc715101 to your computer and use it in GitHub Desktop.
Save nietzscheson/36a14e4fe821cc715101 to your computer and use it in GitHub Desktop.
#Symfony, #Twig - Modal Embed
{% set _title = block('title') %}
{% set _body = block('body') %}
<div class="modal fade {% if type is defined %} bs-example-modal-{{ type }} {% endif %}" id="{{ id|default('modal')}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog {% if type is defined %} modal-{{ type }} {% endif %}" role="document">
<div class="modal-content">
{% if _title is not empty %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">
{{ _title|raw }}
</h4>
</div>
{% endif %}
<div class="modal-body">
{% if _body is not empty %}{{ _body|raw }}{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
{% embed 'MyBundle::Components/modal.html.twig' with { id: 'myModal', type: 'sm'}%}
{% block title %}
# Title
{% endblock %}
{% block body %}
# Content
{% endblock %}
{% endembed %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment