Open jmuzina opened 2 months ago
Thank you for reporting us your feedback!
The internal ticket has been created: https://warthogs.atlassian.net/browse/WD-14598.
This message was autogenerated
I believe this is in progress with jinja macro snippets. So triaging it as part of current codebase.
The code that is sent to CodePen is not formatted by js-beautify like the code shown in our code snippets is.
We should more consistently apply this formatting so that the code is formatted in one place, and the formatting result is used by both the example code snippets and CodePen.
Context
Here's the code path that the (correctly formatted) code snippet code follows:
createPreCode
is called onhtmlSource
https://github.com/canonical/vanilla-framework/blob/510f79dcac1b426f145f1324c214dc2f9f03993e/templates/static/js/example.js#L148createPreCode
callsformatSource
, which calls the relevant js-beautify formatter. https://github.com/canonical/vanilla-framework/blob/510f79dcac1b426f145f1324c214dc2f9f03993e/templates/static/js/example.js#L82-L85Here's the code that is defining what is sent to CodePen: https://github.com/canonical/vanilla-framework/blob/510f79dcac1b426f145f1324c214dc2f9f03993e/templates/static/js/example.js#L114-L123
We are using
htmlSource
, which is not formatted (it is later passed intocreatePreCode
as discussed above). Maybe we should formathtmlSource
,jsSource
, andcssSource
at their initialization, rather than doing it increatePreCode
.