Package: govuk-frontend-jinja
GOV.UK Frontend Jinja MacrosGOV.UK Frontend Jinja is acommunity toolof theGOV.UK Design System. The Design System team is not responsible for it and cannot support you with using it. Contact themaintainersdirectly if you needhelpor you want to request a feature.This repository provides a complete set ofJinjamacros that are kept up-to-date and 100% compliant with the originalGOV.UK FrontendNunjucks macros. Porting is intentionally manual rather than automated to make updates simpler than maintaining an automated conversion routine. Acomprehensive test suiteensures compliance against the latest, and every subsequent, GOV.UK Frontend release.If you are looking to build a fully featured Flask app that integrates withGOV.UK Frontend JinjaandGOV.UK Frontend WTFormsplease use theGOV.UK Frontend Flasktemplate repository togenerate your app.CompatibilityThe following table shows the version of GOV.UK Frontend Jinja that you should use for your targeted version of GOV.UK Frontend:GOV.UK Frontend Jinja VersionTarget GOV.UK Frontend Version3.0.05.1.02.8.04.8.02.7.04.7.02.6.04.6.02.5.04.5.02.4.04.4.12.3.04.2.02.2.04.1.02.1.04.0.12.0.04.0.01.5.13.14.01.4.03.13.01.3.03.12.01.2.13.11.01.1.03.10.21.0.03.8.10.2.13.7.0Any other versions of GOV.UK Frontend not shown abovemaystill be compatible, but have not been specifically tested and verified.How to useAfter runningpip install govuk-frontend-jinja, ensure that you tell Jinja where to load the templates from using thePackageLoaderas follows:fromflaskimportFlaskfromjinja2importChoiceLoader,PackageLoader,PrefixLoaderapp=Flask(__name__)app.jinja_loader=ChoiceLoader([PackageLoader("app"),PrefixLoader({"govuk_frontend_jinja":PackageLoader("govuk_frontend_jinja")}),])Calling a Macro in your templateTo use a component in your project templates you must import and call the component macro and pass the relevant options, for example:{%- from 'govuk_frontend_jinja/components/button/macro.html' import govukButton -%}

{{ govukButton({
  'text': "Save and continue"
}) }}The options available to each component macro can be found in the originalGOV.UK Design System Componentsdocumentation. Since this project is a like-for-like port, the only difference between the Nunjucks examples and their Jinja equivalents is having to quote key names, e.g.'text'instead oftext.Running the testsThe tests are run in a GitHub actions pipeline but if you want to run them locally you will need to installgovuk-frontend-diff.There is a test server attests/utils/app.pywhich you will need to run using the following command:(cdtests/utils&&python-mflaskrun--port3000)You can then run the tests usinggovuk-frontend-diffas follows:./govuk-frontend-diffhttp://localhost:3000--govuk-frontend-version=v4.8.0This is all wrapped up in./test.shfor simplified running (Requires Docker).VersioningWe useSemVerfor versioning. For the versions available, see thetags on this repository.How to contributeWe welcome contribution from the community. If you want to contribute to this project, please review thecode of conductandcontribution guidelines.Update methodologyHow to update this package following a new release of GOV.UK Frontend:Ongovuk-frontend, compare the last compatible tag and the latest tag, e.g.https://github.com/alphagov/govuk-frontend/compare/v4.3.1...v4.4.0If there are any changes to templates inpackage/govuk/components/<component>/template.njkread the diff and apply the same changes to the Jinja equivalent templates ingovuk_frontend_jinja/templates/components/<component>/macro.htmlTake into account any idiosyncrasies between how Nunjucks and Jinja would interpret that template. E.g.Nonechecking nested attributes, checking array items lengths or logic operators such asis,notandin.Run the testsas described aboveResolve any failing tests by comparing the expected HTML output with the actual HTML reported by the test toolAdd a new row to thecompatibility tableabove to show which version of GOV.UK Frontend the next release of this package will be targeting.Once all tests are passing follow thecontribution guidelinesto raise a pull request.After the pull request has been merged,create a new releaseand tag following SemVer conventions.GitHub Actionswill run on the new tag to build the package and publish it to PyPI. Verify that the package has been updated with the latest release tag by checkingthe project pageContributorsMatt Shaw(Primary maintainer)Andy Mantell(Original author)See the full list ofcontributors on GitHubSupportThis software is provided"as-is"without warranty. Support is provided on a"best endeavours"basis by the maintainers and open source community.If you are a civil servant you can sign up to theUK Government Digital Slackworkspace to contact the maintainers listedaboveand the community of people using this project in the#govuk-design-systemchannel.Otherwise, please see thecontribution guidelinesfor how to raise a bug report or feature request.