Skip to content

Commit 6fa816e

Browse files
Refactor and move layouts and templates
1 parent 2d1dc0d commit 6fa816e

File tree

6 files changed

+34
-39
lines changed

6 files changed

+34
-39
lines changed

app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ app.use(cookieParser());
5151
// Nunjucks configuration for application
5252
const appViews = [
5353
path.join(__dirname, 'app/views/'),
54+
path.join(__dirname, 'app/views/_templates'),
55+
path.join(__dirname, 'app/views/_includes'),
5456
path.join(__dirname, 'docs/views/'),
5557
path.join(__dirname, 'lib/prototype-admin/'),
5658
path.join(__dirname, 'node_modules/nhsuk-frontend/packages/components'),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
{% extends "layout.html" %}
3+
4+
5+
{% block content %}
6+
<div class="nhsuk-grid-row">
7+
<div class="nhsuk-grid-column-two-thirds">
8+
{% if formAction or isForm %}
9+
<form action="{{formAction or 'GET'}}">
10+
{% endif %}
11+
{% block pageContent %}{% endblock %}
12+
{% if formAction or isForm %}
13+
</form>
14+
{% endif %}
15+
</div>
16+
</div>
17+
{% endblock %}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
{% endblock %}
1414

1515
<!-- Set the page title -->
16-
{% block pageTitle %}
17-
NHS.UK prototype kit
18-
{% endblock %}
16+
{% block pageTitle -%}
17+
{%- if pageHeading -%}
18+
{{- pageHeading }} -
19+
{%- endif -%}
20+
{{- serviceName }} - NHS
21+
{%- endblock %}
1922

2023
<!-- Edit the header -->
2124
<!-- Header code examples can be found at https://service-manual.nhs.uk/design-system/components/header -->
@@ -51,7 +54,7 @@
5154
{% block bodyEnd %}
5255
{% block scripts %}
5356
<!-- Custom JavaScript files can be added to this file -->
54-
{% include "includes/scripts.html" %}
57+
{% include "_includes/scripts.html" %}
5558
<!-- For adding page specific JavsScript -->
5659
{% block pageScripts %}{% endblock %}
5760
{% endblock %}

app/views/index.html

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
1-
<!-- Use this page as the index for your project -->
21

3-
<!-- ADDING CUSTOM CSS - Add your custom CSS or Sass in /app/assets/sass/main.scss -->
2+
{% extends 'layout-app.html' %}
43

5-
<!-- Extends the layout from /views/layout.html -->
6-
{% extends 'layout.html' %}
7-
<!--
8-
In /views/layout.html you can:
9-
- change the header and footer
10-
- add custom CSS and JavaScript
11-
-->
4+
{% set formAction = "foo" %}
125

13-
<!-- Set the page title -->
14-
{% block pageTitle %}
15-
{{serviceName}}
16-
{% endblock %}
17-
18-
<!-- For adding a breadcrumb or back link -->
19-
<!-- Code examples can be found at https://service-manual.nhs.uk/design-system/components/breadcrumbs and https://service-manual.nhs.uk/design-system/components/back-link -->
20-
{% block beforeContent %}
21-
{% endblock %}
226

7+
{% block pageContent %}
238

24-
<!-- For adding page content -->
25-
<!-- Page layout code can be found at https://service-manual.nhs.uk/design-system/styles/layout -->
26-
{% block content %}
27-
<div class="nhsuk-grid-row">
28-
<div class="nhsuk-grid-column-two-thirds">
29-
30-
<!-- Change the page title here -->
31-
<h1>
32-
{{serviceName}}
33-
<span class="nhsuk-caption-xl nhsuk-caption--bottom">Prototype kit {{version}}</span>
34-
</h1>
35-
36-
37-
<!-- End of content -->
9+
<h1>
10+
{{serviceName}}
11+
<span class="nhsuk-caption-xl nhsuk-caption--bottom">Prototype kit {{version}}</span>
12+
</h1>
3813

39-
</div>
40-
</div>
4114
{% endblock %}

docs/views/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
{% block bodyEnd %}
3535
{% block scripts %}
36-
{% include "includes/scripts.html" %}
36+
{% include "_includes/scripts.html" %}
3737
{% block pageScripts %}{% endblock %}
3838
{% endblock %}
3939
{% endblock %}

0 commit comments

Comments
 (0)