Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example of passing data in Nunjucks macros #563

Merged
merged 2 commits into from
Jul 26, 2018

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Jul 24, 2018

Passing of stored data to Nunjucks macros is something we've seen being asked about.
This just adds the example code to the guidance, not replace the actual working example.

Addresses: #554 and #564

@kr8n3r kr8n3r force-pushed the use-macro-in-data-pass-example branch from a5b8f23 to 24f3d18 Compare July 24, 2018 08:52
@kr8n3r kr8n3r changed the title Add example of using data in Nunjucks macros Add example of passing data in Nunjucks macros Jul 24, 2018
@kr8n3r kr8n3r force-pushed the use-macro-in-data-pass-example branch from 24f3d18 to 4f28f5d Compare July 24, 2018 12:07
<p>Example using the 'checked' function in a radio component macro:</p>

<pre class="app-code"><code>{% raw %}
{{ govukRadios({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove all the indent here? It adds unnecessary indent to the code example, because of the <pre>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, updated

@kr8n3r kr8n3r force-pushed the use-macro-in-data-pass-example branch from 4f28f5d to f3c256f Compare July 25, 2018 13:48
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @igloosi.

I suggest we make it clearer what page this code refers to (left a comment to this end).

When I place the macro in vehicle-features.html, it gets passed to "Check your answers" as an array of letters it looks like (see screen grab). I might be missing a step, would be good to document what's going wrong 🤔

screen shot 2018-07-26 at 09 56 24

Using the data in Nunjucks macros
</h3>

<p>Example using the 'checked' function in a radio component macro:</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding something like:

"The HTML example of this page is available on Vehicle features."

This would help to signpost to the relevant page and call out the Nunjucks/HTML distinction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already tell people how to use checked in html on this page, so I don't think we need to do this too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a radio component macro
should be
in a checkbox macro (do we need 'component'?)

@kr8n3r
Copy link
Author

kr8n3r commented Jul 26, 2018

this work doesn't update the example.
if we were to update it with macros then we'd need to remove the loop as well in the check-answers section

@joelanman
Copy link
Contributor

Using a macro shouldn't break the behaviour here, something is odd

@kr8n3r
Copy link
Author

kr8n3r commented Jul 26, 2018

yes, using radio macro in the features part instead of checkboxes. which i've updated now

@kr8n3r kr8n3r force-pushed the use-macro-in-data-pass-example branch from f3c256f to 2db7e99 Compare July 26, 2018 09:41
Using the data in Nunjucks macros
</h3>

<p>Example using the 'checked' function in a radio component macro:</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a radio component macro
should be
in a checkbox macro (do we need 'component'?)

@kr8n3r kr8n3r force-pushed the use-macro-in-data-pass-example branch from 2db7e99 to bf5e545 Compare July 26, 2018 10:20
Copy link
Contributor

@joelanman joelanman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kr8n3r kr8n3r merged commit 7936071 into master Jul 26, 2018
@kr8n3r kr8n3r deleted the use-macro-in-data-pass-example branch July 26, 2018 10:55
@joelanman joelanman mentioned this pull request Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants