From e45bb3afec29b5eafdca018ea4d027988561d776 Mon Sep 17 00:00:00 2001 From: Jani Kraner Date: Tue, 24 Jul 2018 09:44:34 +0100 Subject: [PATCH 1/2] Add example of using data in Nunjucks macros --- docs/views/examples/pass-data/index.html | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/views/examples/pass-data/index.html b/docs/views/examples/pass-data/index.html index 81fcef3ea9..ebfb61b2d8 100644 --- a/docs/views/examples/pass-data/index.html +++ b/docs/views/examples/pass-data/index.html @@ -81,6 +81,46 @@

Advanced features

+

+ Using the data in Nunjucks macros +

+ +

Example using the 'checked' function in a checkbox component macro:

+ +
{% raw %}
+{{ govukCheckboxes({
+  name: "vehicle-features",
+  fieldset: {
+    legend: {
+      text: "Which of these applies to your vehicle?"
+    }
+  },
+  hint: {
+    text: "Select all that apply"
+  },
+  items: [
+    {
+      value: "Heated seats",
+      text: "Heated seats",
+      id: "vehicle-features-heated-seats",
+      checked: checked("vehicle-features", "Heated seats")
+    },
+    {
+      value: "GPS",
+      text: "GPS",
+      id: "vehicle-features-gps",
+      checked: checked("vehicle-features", "GPS")
+    },
+    {
+      value: "Radio",
+      text: "Radio",
+      id: "vehicle-features-radio",
+      checked: checked("vehicle-features", "Radio")
+    }
+  ]
+}) }}
+{% endraw %}
+

Using the data on the server

From bf5e5451d13c620633743126dd2728253cf2da3a Mon Sep 17 00:00:00 2001 From: Jani Kraner Date: Tue, 24 Jul 2018 09:49:55 +0100 Subject: [PATCH 2/2] Document in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb180d2e46..6a15599415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Unreleased New features: - +- [#563 Add Nunjucks macro example to 'passing data' guidance](https://github.com/alphagov/govuk-prototype-kit/pull/563) - [#557 Bump outdated dependencies](https://github.com/alphagov/govuk-prototype-kit/pull/557): - Update standard from 10.0.2 to 11.0.1 and fix violations - Update run-sequence from 1.2.2 to 2.2.1