Supply layout template for other languages (Rails, Python...)
See original GitHub issueWhen implementing the Design System in a Rails app, I am able to include the assets (CSS, JS, fonts, images) easily enough, but the only layout file supplied is template.njk
so I have to manually create views/layouts/application.slim
myself, and then it will degrade over time and need to be recreated when the system is updated.
It would be ace to have a slim
or perhaps just erb
version of the template for Rails apps.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Django switching, for a block of code, switch the language so ...
What do I put in to switch django translations/gettext to a specific language code so that the _() will use that language code?...
Read more >Rails Internationalization (I18n) API - Ruby on Rails Guides
The process of “internationalization” usually means to abstract all strings and other locale specific bits (such as date or currency formats) out of...
Read more >An Introduction to ERB Templating - Field Notes
Rails uses an improved version, called Erubis. The supplied documentation for ERB provides a good introduction: ri ERB. Writing Templates. ERB ...
Read more >Kotlin DSL templates with Python (or any other) Server
Further, the description of page content becomes more concise than with conventional templates. More Languages? Or Less? It could be seen that ...
Read more >Liquid Template Language | Twilio
Learn to use the Liquid Template Language to render dynamic content in ... all whitespace from the beginning of a string; map -...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @leonk,
The script I’ve pasted is fully working so in terms of viability I think it’s a goer. I’m happy that the templates are working correctly, barring any edge case bugs.
I did look meta-template briefly but the readme file suggested it was quite early days so I didn’t pursue it. I proceeded on the assumption that Jinja and Nunjucks were similar enough that a few string replacements would do the trick (true => True, quoting object/dict keys etc). The reality turned out to be a little more painful than I realised, but what I’ve done still mostly amounts to relatively simple string manipulation. The regular expressions got a bit gnarly, but conceptually the transformations weren’t complicated. A lot of the differences (particularly the more annoying ones) were the result of the behaviours of the underlying language. And one that was probably either a bug in Jinja or a bug in Nunjucks, because the GOV.UK Nunjucks implementation just did not work whatever I did (The bit where each component macro simply includes an include, and expects the
params
to still be there)Given that Twig is inspired by Jinja (And actually written by the same guy) you might well get away with a similar process. Basically I kept adding lines to my script until Python stopped throwing errors.
Give it a go 😃
This decision record is also useful context here as it details what was done in alpha and some of the challenges we’ve identified: https://github.com/alphagov/govuk-design-system-architecture/blob/master/decision-records/003-templating-languages.md