Refactor templates to be more structured
This commit is contained in:
parent
be5e457d1b
commit
a5619e2307
@ -132,7 +132,7 @@ class SnipController extends AbstractController
|
||||
return $this->redirectToRoute('snip_index');
|
||||
}
|
||||
|
||||
return $this->render('form.html.twig', [
|
||||
return $this->render('generic/form.html.twig', [
|
||||
'message' => sprintf('Do you really want to delete "%s"?', $snip),
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}SNIPS{% endblock %}</title>
|
||||
<title>{% if title is defined %}{{ title }}{% else %}SNIPS{% endif %}</title>
|
||||
<link rel="shortcut icon" type="image/jpg" href="/favicon.png">
|
||||
|
||||
{% block css %}
|
||||
@ -37,19 +37,7 @@
|
||||
</div>
|
||||
|
||||
{# body blocks #}
|
||||
{% block bodyraw %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm mx-auto">
|
||||
{% block body %}{% endblock %}
|
||||
</div>
|
||||
{% if block('body2') is defined %}
|
||||
<div class="col-sm mx-auto">
|
||||
{{ block('body2') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
||||
{# javascript block #}
|
||||
|
8
templates/base/container.html.twig
Normal file
8
templates/base/container.html.twig
Normal file
@ -0,0 +1,8 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
{% block container %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
10
templates/base/single.column.html.twig
Normal file
10
templates/base/single.column.html.twig
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends 'base/container.html.twig' %}
|
||||
|
||||
{% block container %}
|
||||
<div class="row">
|
||||
<div class="col-sm mx-auto">
|
||||
{% if title is defined %}<h3>{{ title }}</h3>{% endif %}
|
||||
{% block body %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,6 +0,0 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h3>{{ message }}</h3>
|
||||
{{ form(form) }}
|
||||
{% endblock %}
|
7
templates/generic/form.html.twig
Normal file
7
templates/generic/form.html.twig
Normal file
@ -0,0 +1,7 @@
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% set title %}{{ message }}{% endset %}
|
||||
|
||||
{% block body %}
|
||||
{{ form(form) }}
|
||||
{% endblock %}
|
5
templates/generic/simple.html.twig
Normal file
5
templates/generic/simple.html.twig
Normal file
@ -0,0 +1,5 @@
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
{{ text | nl2br }}
|
||||
{% endblock %}
|
@ -1,6 +1,6 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block title %}Login{% endblock %}
|
||||
{% set title %}Login{% endset %}
|
||||
|
||||
{% block body %}
|
||||
<form action="{{ path('login') }}" method="post">
|
||||
@ -12,7 +12,6 @@
|
||||
You are already logged in as {{ app.user }}, <a href="{{ path('logout') }}">Logout</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h1 class="h3 mb-3 font-weight-normal">Please login</h1>
|
||||
<label for="inputUsername">Username</label>
|
||||
<input type="text" value="{{ last_username }}" name="_username" id="inputUsername" class="form-control" required
|
||||
autofocus>
|
||||
|
@ -1,8 +1,7 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block title %}Register{% endblock %}
|
||||
{% set title %}Register{% endset %}
|
||||
|
||||
{% block body %}
|
||||
<h1 class="h3 mb-3 font-weight-normal">Register new user</h1>
|
||||
{{ form(registrationForm) }}
|
||||
{% endblock %}
|
@ -1,5 +0,0 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
{{ text | nl2br }}
|
||||
{% endblock %}
|
@ -1,6 +1,6 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block title %}Edit {{ snip }}{% endblock %}
|
||||
{% set title %}Edit {{ snip }}{% endset %}
|
||||
|
||||
{% block body %}
|
||||
{% if snip.id %}
|
||||
@ -13,6 +13,5 @@
|
||||
<i class="fa fa-list"></i>
|
||||
Index
|
||||
</a><br><br>
|
||||
<h2>Editing {{ snip }}</h2>
|
||||
{{ form(form) }}
|
||||
{% endblock %}
|
@ -1,9 +1,6 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>{{ title }}</h1>
|
||||
<a class="btn btn-success" href="{{ path('snip_new') }}">
|
||||
<i class="fa fa-plus"></i> Add
|
||||
</a>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block title %}Snip {{ snip }}{% endblock %}
|
||||
{% set title %}Snip {{ snip }}{% endset %}
|
||||
|
||||
{% block body %}
|
||||
<a href="{{ path('snip_index') }}" class="btn btn-primary">
|
||||
|
@ -1,9 +1,9 @@
|
||||
{% extends "base/base.html.twig" %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<h4>{{ app.user.name }}</h4>
|
||||
<h3>{{ app.user.name }}</h3>
|
||||
<br/>
|
||||
{% if is_granted('ROLE_ADMIN') %}
|
||||
<br/><br/>
|
||||
@ -16,7 +16,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<h4>Change profile</h4>
|
||||
<h3>Change profile</h3>
|
||||
{{ form(form) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends 'base/base.html.twig' %}
|
||||
{% extends 'base/single.column.html.twig' %}
|
||||
|
||||
{% block title %}Snip {{ snip }}{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user