From bfef58dfa6b4da157f3d54c8ff381f30fad85e30 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 14:59:00 +0100 Subject: [PATCH 01/20] Add express-nunjucks to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0a616c3c7..cf86309b6 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "body-parser": "^1.14.1", "consolidate": "^0.10.0", "express": "4.13.3", + "express-nunjucks": "^0.9.3", "express-writer": "0.0.4", "govuk_template_mustache": "^0.17.2", "grunt": "^0.4.2", From 2de491fa5700f89409675156d4d697f131f11398 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:11:13 +0100 Subject: [PATCH 02/20] Add express-nunjucks and remove template conversion Remove config files, conversion engine and grunt tasks used for template conversion. Setup nunjucks --- Gruntfile.js | 16 --------- lib/template-conversion.js | 22 ------------ lib/template-engine.js | 73 -------------------------------------- package.json | 2 -- server.js | 14 +++++--- 5 files changed, 9 insertions(+), 118 deletions(-) delete mode 100755 lib/template-conversion.js delete mode 100755 lib/template-engine.js diff --git a/Gruntfile.js b/Gruntfile.js index 8c50ce4a1..9930c8540 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -110,28 +110,14 @@ module.exports = function (grunt) { 'grunt-contrib-watch', 'grunt-sass', 'grunt-nodemon', - 'grunt-text-replace', 'grunt-concurrent', 'grunt-shell' ].forEach(function (task) { grunt.loadNpmTasks(task); }); - grunt.registerTask( - 'convert_template', - 'Converts the govuk_template to use mustache inheritance', - function () { - var script = require(__dirname + '/lib/template-conversion.js'); - - script.convert(); - grunt.log.writeln('govuk_template converted'); - } - ); - grunt.registerTask('default', [ 'copy', - 'convert_template', - 'replace', 'sass', 'concurrent:target' ]); @@ -141,8 +127,6 @@ module.exports = function (grunt) { 'Test that the default task runs the app', [ 'copy', - 'convert_template', - 'replace', 'sass' ] ); diff --git a/lib/template-conversion.js b/lib/template-conversion.js deleted file mode 100755 index 186f42999..000000000 --- a/lib/template-conversion.js +++ /dev/null @@ -1,22 +0,0 @@ -var Hogan = require('hogan.js'), - fs = require('fs'), - path = require('path'), - govukDir = path.normalize(__dirname + '/../govuk_modules/'), - govukConfig = require(__dirname + '/template-config'), - compiledTemplate, - govukTemplate, - handleErr; - -handleErr = function (err) { - if (err) { - throw err; - } -}; - -module.exports = { - convert : function () { - govukTemplate = fs.readFileSync(govukDir + '/govuk_template/views/layouts/govuk_template.html', { encoding : 'utf-8' }); - compiledTemplate = Hogan.compile(govukTemplate); - fs.writeFileSync(govukDir + '/govuk_template/views/layouts/govuk_template.html', compiledTemplate.render(govukConfig), { encoding : 'utf-8' }); - } -}; diff --git a/lib/template-engine.js b/lib/template-engine.js deleted file mode 100755 index 72e2aedea..000000000 --- a/lib/template-engine.js +++ /dev/null @@ -1,73 +0,0 @@ - -var Hogan = require('hogan.js'); -var ReadDir = require('readdir'); -var Path = require('path'); -var FS = require('fs'); - -function TemplateEngine() { -} - -/** - * All active directory file system watches - * @type {fs.FSWatcher[]} - * @ignore - */ -TemplateEngine._watches = []; - -/** - * Called by the express server to get the content for a given template at the templatePath supplied. The templateData - * can contain any content from a configured route, and will be made available to the templates. - * - * Templates can include partials by name for any template also in the views directory, note that if sub-directories are - * used to create included partials, express will not necessarily recognise that file as a valid view path... you've been - * warned. - * - * @param {String} templatePath Path to the template - * @param {Object} templateData Data to give to the template - * @param {Function} next Callback to receive two arguments, an error object and the template result. - */ -TemplateEngine.__express = function(templatePath, templateData, next) { - var templateName = Path.basename(templatePath, Path.extname(templatePath)); - var templates = TemplateEngine._getTemplates([templateData.settings.views, templateData.settings.vendorViews]); - var output = null, error = null; - - try { - output = templates[templateName].render(templateData, templates); - } - catch (e) { - error = e; - } - finally { - next(error, output); - } -}; - -/** - * Stores an individual template based on the supplied path, the name of the template is the file's basename without - * the extension. - * - * @param {String} templatePath - */ -TemplateEngine._storeTemplate = function(templatePath) { - var templateName = Path.basename(templatePath, Path.extname(templatePath)); - TemplateEngine.__templates[templateName] = Hogan.compile(FS.readFileSync(templatePath, 'utf-8')); - - console.log('Stored template', templateName); -}; - -/** - * Gets all templates, when the template path hasn't yet been scanned it will be read synchronously to ensure there are - * always templates available. - * - * @param {Array} templatePaths - */ -TemplateEngine._getTemplates = function(templatePaths) { - TemplateEngine.__templates = {}; - for (var i = 0, j = templatePaths.length; i < j; i++) { - ReadDir.readSync(templatePaths[i], ['**.html'], ReadDir.ABSOLUTE_PATHS) - .forEach(TemplateEngine._storeTemplate, TemplateEngine); - } - return TemplateEngine.__templates; -}; - -module.exports = TemplateEngine; diff --git a/package.json b/package.json index cf86309b6..b59c9dcb7 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,6 @@ "grunt-nodemon": "^0.3.0", "grunt-sass": "^1.0.0", "grunt-shell": "^1.3.0", - "grunt-text-replace": "^0.3.12", - "hogan.js": "3.0.2", "node-sass": "^3.2.0", "readdir": "0.0.6" }, diff --git a/server.js b/server.js index 022ff225f..82b13b692 100755 --- a/server.js +++ b/server.js @@ -1,14 +1,18 @@ -var express = require('express'), - bodyParser = require('body-parser'), +var bodyParser = require('body-parser'), + express = require('express'), + nunjucks = require('express-nunjucks'), routes = require(__dirname + '/app/routes.js'), app = express(), port = (process.env.PORT || 3000); // Application settings -app.engine('html', require(__dirname + '/lib/template-engine.js').__express); app.set('view engine', 'html'); -app.set('vendorViews', __dirname + '/govuk_modules/govuk_template/views/layouts'); -app.set('views', __dirname + '/app/views'); +app.set('views', [__dirname + '/app/views', __dirname + '/lib/']); + +nunjucks.setup({ + autoescape: true, + watch: true +}, app); // Middleware to serve static assets app.use('/public', express.static(__dirname + '/public')); From a11696467861fa2f990b2d25d84cae24e740d6b0 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:13:02 +0100 Subject: [PATCH 03/20] Add the jinja version of the govuk template as a dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b59c9dcb7..2832ac19f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "express": "4.13.3", "express-nunjucks": "^0.9.3", "express-writer": "0.0.4", - "govuk_template_mustache": "^0.17.2", + "govuk_template_jinja": "https://github.com/alphagov/govuk_template/releases/download/v0.17.2/jinja_govuk_template-0.17.2.tgz", "grunt": "^0.4.2", "grunt-cli": "0.1.13", "grunt-concurrent": "^0.4.3", From ccdbebd9027ebcbce8dea9e21706f2d20d329814 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:14:22 +0100 Subject: [PATCH 04/20] Copy the jinja version of the template to govuk modules --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9930c8540..d6d7e4719 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -46,7 +46,7 @@ module.exports = function (grunt) { }, { expand: true, - cwd: 'node_modules/govuk_template_mustache/', + cwd: 'node_modules/govuk_template_jinja/', src: '**', dest: 'govuk_modules/govuk_template/' }] From c70cead6b9b46fb736aac52785c876d403a9d602 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:18:16 +0100 Subject: [PATCH 05/20] Copy the govuk_template layout file to /lib Add this copied file to the .gitignore file as it is library code and we already have a copy of it in /govuk_modules/ --- .gitignore | 1 + Gruntfile.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0dd8973c6..85f393a34 100755 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .start.pid node_modules govuk_modules +lib/govuk_template.html # Ignore compiled stylesheets public/stylesheets/ diff --git a/Gruntfile.js b/Gruntfile.js index d6d7e4719..6987d0bf9 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,8 +51,15 @@ module.exports = function (grunt) { dest: 'govuk_modules/govuk_template/' }] }, - }, - + govuk_template_jinja: { + files: [{ + expand: true, + cwd: 'govuk_modules/govuk_template/views/layouts/', + src: '**', + dest: 'lib/' + }] + }, + } // workaround for libsass replace: { fixSass: { From 300e07dee51634bc067579c98f6a204ec14c79a8 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:20:30 +0100 Subject: [PATCH 06/20] Update the layout template to extend the govuk template --- app/views/layout.html | 4 +--- app/views/layout_example.html | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/layout.html b/app/views/layout.html index a2ce9b9b0..e894c4be2 100755 --- a/app/views/layout.html +++ b/app/views/layout.html @@ -1,4 +1,4 @@ -{{elements_head}} @@ -12,5 +12,3 @@ {{/propositionHeader}} {{$headerClass}}with-proposition{{/headerClass}} - -{{/govuk_template}} diff --git a/app/views/layout_example.html b/app/views/layout_example.html index 701404e32..ab521ba28 100644 --- a/app/views/layout_example.html +++ b/app/views/layout_example.html @@ -1,4 +1,4 @@ -{{head}} @@ -41,5 +41,3 @@ {{$bodyEnd}} {{>scripts}} {{/bodyEnd}} - -{{/govuk_template}} From 6405fd26a0d1150fe55f9288371859b718387654 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 15:32:03 +0100 Subject: [PATCH 07/20] Use nunjucks syntax for blocks --- app/views/examples/example_date.html | 2 +- app/views/examples/example_details_summary.html | 2 +- app/views/examples/example_form_elements.html | 2 +- .../example_form_validation_multiple_questions.html | 2 +- .../example_form_validation_single_question_radio.html | 2 +- app/views/examples/example_grid_layout.html | 6 +++--- app/views/examples/example_icons.html | 2 +- app/views/examples/example_radios_checkboxes.html | 2 +- app/views/examples/example_typography.html | 2 +- app/views/guide_alpha_beta.html | 6 +++--- app/views/guide_buttons.html | 6 +++--- app/views/guide_colour.html | 6 +++--- app/views/guide_data.html | 6 +++--- app/views/guide_errors.html | 6 +++--- app/views/guide_form_elements.html | 6 +++--- app/views/guide_icons_images.html | 6 +++--- app/views/guide_layout.html | 6 +++--- app/views/guide_typography.html | 6 +++--- app/views/index.html | 6 +++--- app/views/layout_example.html | 4 ++-- 20 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/views/examples/example_date.html b/app/views/examples/example_date.html index b40c3ecc2..0312af7eb 100644 --- a/app/views/examples/example_date.html +++ b/app/views/examples/example_date.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_details_summary.html b/app/views/examples/example_details_summary.html index ef3b7eabc..376927596 100644 --- a/app/views/examples/example_details_summary.html +++ b/app/views/examples/example_details_summary.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_form_elements.html b/app/views/examples/example_form_elements.html index 594e385c1..d43981b7d 100644 --- a/app/views/examples/example_form_elements.html +++ b/app/views/examples/example_form_elements.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_form_validation_multiple_questions.html b/app/views/examples/example_form_validation_multiple_questions.html index fbc51aeab..038c1527f 100644 --- a/app/views/examples/example_form_validation_multiple_questions.html +++ b/app/views/examples/example_form_validation_multiple_questions.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_form_validation_single_question_radio.html b/app/views/examples/example_form_validation_single_question_radio.html index 18704fa2c..65d046445 100644 --- a/app/views/examples/example_form_validation_single_question_radio.html +++ b/app/views/examples/example_form_validation_single_question_radio.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_grid_layout.html b/app/views/examples/example_grid_layout.html index b476fce7e..a4adfb787 100644 --- a/app/views/examples/example_grid_layout.html +++ b/app/views/examples/example_grid_layout.html @@ -1,6 +1,6 @@ {{ @@ -130,7 +130,7 @@

One quarter

{{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout_example}} diff --git a/app/views/examples/example_icons.html b/app/views/examples/example_icons.html index c5ca5f2df..34ad2e1f8 100644 --- a/app/views/examples/example_icons.html +++ b/app/views/examples/example_icons.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_radios_checkboxes.html b/app/views/examples/example_radios_checkboxes.html index a95ab5060..72886cd3a 100644 --- a/app/views/examples/example_radios_checkboxes.html +++ b/app/views/examples/example_radios_checkboxes.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/examples/example_typography.html b/app/views/examples/example_typography.html index 2db3405af..26d724114 100644 --- a/app/views/examples/example_typography.html +++ b/app/views/examples/example_typography.html @@ -1,6 +1,6 @@ {{ diff --git a/app/views/guide_alpha_beta.html b/app/views/guide_alpha_beta.html index 59bbc5ca3..a3a2b53f8 100755 --- a/app/views/guide_alpha_beta.html +++ b/app/views/guide_alpha_beta.html @@ -1,6 +1,6 @@ {{Creating alpha and beta b {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_buttons.html b/app/views/guide_buttons.html index 1c0afd1ba..b856e5e46 100755 --- a/app/views/guide_buttons.html +++ b/app/views/guide_buttons.html @@ -1,6 +1,6 @@ {{Focus {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_colour.html b/app/views/guide_colour.html index 11b056618..d7506c03d 100755 --- a/app/views/guide_colour.html +++ b/app/views/guide_colour.html @@ -1,6 +1,6 @@ {{ {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_data.html b/app/views/guide_data.html index 6583bbc36..61ee55319 100755 --- a/app/views/guide_data.html +++ b/app/views/guide_data.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_errors.html b/app/views/guide_errors.html index 66b9701ab..b13bce8b0 100755 --- a/app/views/guide_errors.html +++ b/app/views/guide_errors.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_form_elements.html b/app/views/guide_form_elements.html index 0262f6035..291528c01 100755 --- a/app/views/guide_form_elements.html +++ b/app/views/guide_form_elements.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_icons_images.html b/app/views/guide_icons_images.html index 3970b010f..461aaa08f 100755 --- a/app/views/guide_icons_images.html +++ b/app/views/guide_icons_images.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_layout.html b/app/views/guide_layout.html index 02913d16e..fc4518b34 100755 --- a/app/views/guide_layout.html +++ b/app/views/guide_layout.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/guide_typography.html b/app/views/guide_typography.html index 546caeeb1..bcfaea96d 100755 --- a/app/views/guide_typography.html +++ b/app/views/guide_typography.html @@ -1,6 +1,6 @@ {{Examples {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/index.html b/app/views/index.html index 859d9f36e..15124e0d5 100755 --- a/app/views/index.html +++ b/app/views/index.html @@ -1,6 +1,6 @@ {{Want to discuss these patterns? {{/content}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} {{/layout}} diff --git a/app/views/layout_example.html b/app/views/layout_example.html index ab521ba28..2ace2de35 100644 --- a/app/views/layout_example.html +++ b/app/views/layout_example.html @@ -38,6 +38,6 @@ {{$headerClass}}with-proposition{{/headerClass}} -{{$bodyEnd}} +{% block body_end %} {{>scripts}} -{{/bodyEnd}} +{% endblock %} From 5d1cfcd581cb54ed8fa2d4f54d00b7e54005dd46 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:22:08 +0100 Subject: [PATCH 08/20] Use nunjucks syntax - For blocks - For includes - The scripts include exists in both layout templates, so remove this from the bottom of any child templates which use a layout or layout_example template --- app/views/examples/example_date.html | 12 ++-- .../examples/example_details_summary.html | 10 ++-- app/views/examples/example_form_elements.html | 22 ++++--- ...le_form_validation_multiple_questions.html | 12 ++-- ...form_validation_single_question_radio.html | 12 ++-- app/views/examples/example_grid_layout.html | 12 ++-- app/views/examples/example_icons.html | 10 ++-- .../examples/example_radios_checkboxes.html | 10 ++-- app/views/examples/example_typography.html | 10 ++-- app/views/guide_alpha_beta.html | 22 +++---- app/views/guide_buttons.html | 24 +++----- app/views/guide_colour.html | 14 ++--- app/views/guide_data.html | 22 +++---- app/views/guide_errors.html | 26 ++++----- app/views/guide_form_elements.html | 58 +++++++++---------- app/views/guide_icons_images.html | 20 +++---- app/views/guide_layout.html | 38 +++++------- app/views/guide_typography.html | 48 +++++++-------- app/views/includes/breadcrumb.html | 4 +- app/views/index.html | 35 +++++------ app/views/layout.html | 30 ++++++---- app/views/layout_example.html | 20 ++++--- lib/template-config.js | 4 +- 23 files changed, 206 insertions(+), 269 deletions(-) diff --git a/app/views/examples/example_date.html b/app/views/examples/example_date.html index 0312af7eb..2d0d51495 100644 --- a/app/views/examples/example_date.html +++ b/app/views/examples/example_date.html @@ -1,11 +1,11 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
@@ -15,12 +15,10 @@

Example: Date

- {{> form_date }} + {% include "snippets/form_date.html" %}
-{{/content}} - -{{/layout_example}} +{% endblock %} diff --git a/app/views/examples/example_details_summary.html b/app/views/examples/example_details_summary.html index 376927596..ef50e35c3 100644 --- a/app/views/examples/example_details_summary.html +++ b/app/views/examples/example_details_summary.html @@ -1,11 +1,11 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
@@ -87,6 +87,4 @@

Example 3: Summary content is visible, details conten

-{{/content}} - -{{/layout_example}} +{% endblock %} diff --git a/app/views/examples/example_form_elements.html b/app/views/examples/example_form_elements.html index d43981b7d..1e9c3abc7 100644 --- a/app/views/examples/example_form_elements.html +++ b/app/views/examples/example_form_elements.html @@ -1,11 +1,11 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
@@ -501,37 +501,35 @@

These examples are one-question-per-page examples and use a heading for the question, with a visually hidden legend inside a fieldset.

- {{> form_radio_buttons }} + {% include "snippets/form_radio_buttons.html" %}
- {{> form_checkboxes }} + {% include "snippets/form_checkboxes.html" %}
- {{> form_radio_buttons_inline }} + {% include "snippets/form_radio_buttons_inline.html" %}
- {{> form_radio_inline_yes_no }} + {% include "snippets/form_radio_inline_yes_no.html" %}
- {{> form_inset_radios }} + {% include "snippets/form_inset_radios.html" %}
- {{> form_inset_checkboxes }} + {% include "snippets/form_inset_checkboxes.html" %}
-{{/content}} - -{{/layout_example}} +{% endblock %} diff --git a/app/views/examples/example_form_validation_multiple_questions.html b/app/views/examples/example_form_validation_multiple_questions.html index 038c1527f..a336a40d8 100644 --- a/app/views/examples/example_form_validation_multiple_questions.html +++ b/app/views/examples/example_form_validation_multiple_questions.html @@ -1,17 +1,17 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
- {{> form_error_multiple }} + {% include "snippets/form_error_multiple.html" %}

Implementation advice

@@ -65,6 +65,4 @@

Implementation advice

-{{/content}} - -{{/layout_example}} +{% endblock %} diff --git a/app/views/examples/example_form_validation_single_question_radio.html b/app/views/examples/example_form_validation_single_question_radio.html index 65d046445..4437a2c57 100644 --- a/app/views/examples/example_form_validation_single_question_radio.html +++ b/app/views/examples/example_form_validation_single_question_radio.html @@ -1,17 +1,17 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
- {{> form_error_radio }} + {% include "snippets/form_error_radio.html" %}

Implementation advice

@@ -71,6 +71,4 @@

Implementation advice

-{{/content}} - -{{/layout_example}} +{% endblock %} diff --git a/app/views/examples/example_grid_layout.html b/app/views/examples/example_grid_layout.html index a4adfb787..f7fc9cfff 100644 --- a/app/views/examples/example_grid_layout.html +++ b/app/views/examples/example_grid_layout.html @@ -1,11 +1,11 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %}
@@ -128,10 +128,10 @@

One quarter

-{{/content}} +{% endblock %} {% block body_end %} - {{>scripts}} + {% include "scripts.html" %} {% endblock %} - -{{/layout_example}} diff --git a/app/views/examples/example_icons.html b/app/views/examples/example_icons.html index 34ad2e1f8..ca3754082 100644 --- a/app/views/examples/example_icons.html +++ b/app/views/examples/example_icons.html @@ -1,11 +1,11 @@ -{{ - {{>breadcrumb}} + {% include "includes/breadcrumb.html" %} - {{>elements_tracking}} -{{/head}} + {% include "includes/elements_tracking.html" %} +{% endblock %} -{{$propositionHeader}} - {{>service_manual_navigation}} -{{/propositionHeader}} +{% block proposition_header %} + {% include "includes/service_manual_navigation.html" %} +{% endblock %} -{{$headerClass}}with-proposition{{/headerClass}} +{% block header_class %} + with-proposition +{% endblock %} {% block body_end %} - {{>scripts}} + {% include "includes/scripts.html" %} {% endblock %} diff --git a/lib/template-config.js b/lib/template-config.js index 9d2562a83..7b9b7733a 100755 --- a/lib/template-config.js +++ b/lib/template-config.js @@ -2,7 +2,7 @@ module.exports = { assetPath: "{{assetPath}}", afterHeader: "{{$afterHeader}}{{/afterHeader}}", bodyClasses: "{{$bodyClasses}}{{/bodyClasses}}", - bodyEnd: "{{$bodyEnd}}{{/bodyEnd}}", + bodyEnd: "{% block body_end %}{% endblock %}", content: "{{$content}}{{/content}}", cookieMessage: "{{$cookieMessage}}

GOV.UK uses cookies to make the site simpler. Find out more about cookies

{{/cookieMessage}}", crownCopyrightMessage: "{{$crownCopyrightMessage}}© Crown copyright{{/crownCopyrightMessage}}", @@ -15,7 +15,7 @@ module.exports = { insideHeader: "{{$insideHeader}}{{/insideHeader}}", licenceMessage: "{{$licenceMessage}}

All content is available under the Open Government Licence v3.0, except where otherwise stated

{{/licenceMessage}}", logoLinkTitle: "{{$logoLinkTitle}}Go to the GOV.UK homepage{{/logoLinkTitle}}", - pageTitle: "{{$pageTitle}}GOV.UK - The best place to find government services and information{{/pageTitle}}", + pageTitle: "{% block page_title %}GOV.UK - The best place to find government services and information{% endblock %}", propositionHeader: "{{$propositionHeader}}{{/propositionHeader}}", skipLinkMessage: "{{$skipLinkMessage}}Skip to main content{{/skipLinkMessage}}" }; From 0b583aa929b3408e51c197a3e42e87357da45d1a Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:29:14 +0100 Subject: [PATCH 09/20] Update if/else statements for the breadcrumb --- app/views/includes/breadcrumb.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/includes/breadcrumb.html b/app/views/includes/breadcrumb.html index e3f6a592f..26b879367 100644 --- a/app/views/includes/breadcrumb.html +++ b/app/views/includes/breadcrumb.html @@ -1,11 +1,11 @@ From d8ebc9ee63eb39d57323dcb1d81e51fb1ff1a7a9 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:29:35 +0100 Subject: [PATCH 10/20] Rename assetPath to asset_path to match the govuk template --- app/routes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes.js b/app/routes.js index 9f9a0b276..39cdff942 100755 --- a/app/routes.js +++ b/app/routes.js @@ -1,8 +1,8 @@ module.exports = { - bind : function (app, assetPath) { + bind : function (app, asset_path) { app.get('/', function (req, res) { - res.render('index', {'assetPath' : assetPath }); + res.render('index', {'asset_path' : asset_path }); }); // Redirect snippets page to the index page From 5322abad48a9e4dd0b8af202544a90cc52d1dbd4 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:54:12 +0100 Subject: [PATCH 11/20] Remove the template config file which isn't used --- lib/template-config.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 lib/template-config.js diff --git a/lib/template-config.js b/lib/template-config.js deleted file mode 100755 index 7b9b7733a..000000000 --- a/lib/template-config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - assetPath: "{{assetPath}}", - afterHeader: "{{$afterHeader}}{{/afterHeader}}", - bodyClasses: "{{$bodyClasses}}{{/bodyClasses}}", - bodyEnd: "{% block body_end %}{% endblock %}", - content: "{{$content}}{{/content}}", - cookieMessage: "{{$cookieMessage}}

GOV.UK uses cookies to make the site simpler. Find out more about cookies

{{/cookieMessage}}", - crownCopyrightMessage: "{{$crownCopyrightMessage}}© Crown copyright{{/crownCopyrightMessage}}", - footerSupportLinks: "{{$footerSupportLinks}}{{/footerSupportLinks}}", - footerTop: "{{$footerTop}}{{/footerTop}}", - globalHeaderText: "{{$globalHeaderText}}GOV.UK{{/globalHeaderText}}", - head: "{{$head}}{{/head}}", - headerClass: "{{$headerClass}}{{/headerClass}}", - homepageUrl: "{{$homepageUrl}}https://www.gov.uk{{/homepageUrl}}", - insideHeader: "{{$insideHeader}}{{/insideHeader}}", - licenceMessage: "{{$licenceMessage}}

All content is available under the Open Government Licence v3.0, except where otherwise stated

{{/licenceMessage}}", - logoLinkTitle: "{{$logoLinkTitle}}Go to the GOV.UK homepage{{/logoLinkTitle}}", - pageTitle: "{% block page_title %}GOV.UK - The best place to find government services and information{% endblock %}", - propositionHeader: "{{$propositionHeader}}{{/propositionHeader}}", - skipLinkMessage: "{{$skipLinkMessage}}Skip to main content{{/skipLinkMessage}}" -}; From 21934a8accc6f65cfd4300f9ad19eefc6bcacffa Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:54:27 +0100 Subject: [PATCH 12/20] Fix indentation, add trailing comma --- Gruntfile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6987d0bf9..1a4148efb 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,7 +59,8 @@ module.exports = function (grunt) { dest: 'lib/' }] }, - } + }, + // workaround for libsass replace: { fixSass: { @@ -146,7 +147,7 @@ module.exports = function (grunt) { } ); - grunt.registerTask( + grunt.registerTask( 'lint_message', 'Output a message once linting is complete', function() { From bc3c9785ec1c4f15c3e2d49ac36e4bf12c9a8aa6 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:55:15 +0100 Subject: [PATCH 13/20] Add path to server.js --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index 82b13b692..7010d8fce 100755 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ var bodyParser = require('body-parser'), express = require('express'), nunjucks = require('express-nunjucks'), + path = require('path'), routes = require(__dirname + '/app/routes.js'), app = express(), port = (process.env.PORT || 3000); From f0b4502893ac01b90001287612169996cce7c91b Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:59:04 +0100 Subject: [PATCH 14/20] Rename asset_path in server.js --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 7010d8fce..621cccf9d 100755 --- a/server.js +++ b/server.js @@ -29,7 +29,7 @@ app.use(bodyParser.urlencoded({ // send assetPath to all views app.use(function (req, res, next) { - res.locals.assetPath="/public/"; + res.locals.asset_path="/public/"; next(); }); From 4f619e5ee516155f57827542601bbb1f86c6f8c0 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 16:59:17 +0100 Subject: [PATCH 15/20] Add missing includes folder --- app/views/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/index.html b/app/views/index.html index d5847f9ba..f6948d34c 100755 --- a/app/views/index.html +++ b/app/views/index.html @@ -128,6 +128,6 @@

Want to discuss these patterns?

{% block body_end %} - {% include "scripts.html" %} + {% include "includes/scripts.html" %} {% endblock %} From 69734c995037c47795d8f9d797a5c780568806ca Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 17:22:00 +0100 Subject: [PATCH 16/20] Fix paths to snippets/ and includes/ --- app/views/examples/example_grid_layout.html | 2 +- app/views/guide_form_elements.html | 20 ++++++++++---------- app/views/layout_example.html | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/examples/example_grid_layout.html b/app/views/examples/example_grid_layout.html index f7fc9cfff..587bebeee 100644 --- a/app/views/examples/example_grid_layout.html +++ b/app/views/examples/example_grid_layout.html @@ -131,7 +131,7 @@

One quarter

{% endblock %} {% block body_end %} - {% include "scripts.html" %} + {% include "includes/scripts.html" %}