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 base64Encode handlebars helper #4925

Merged
merged 3 commits into from
Sep 26, 2024
Merged

Conversation

fishface60
Copy link
Contributor

@fishface60 fishface60 commented Sep 15, 2024

Identify the Bug or Feature request

closes #4924

Description of the Change

This adds a handlebars helper called base64Encode that uses the same encoder as the macro, which happens to use the right parameters to pair with the browser's atob function.

Possible Drawbacks

I have not included a base64Decode function because I could not think of what it would be useful for, it's fallible if given the wrong input and would be hard to handle errors in handlebars so people should do it in javascript.

Documentation Notes

base64Encode

Turns the textual form of the value into a base64-encoded string. For example:

<script type="application/json;base64" id="jsonProperty">
  {{ base64Encode properties[0].value }}
</script>
<script type="application/javascript">
const jsonProperty = JSON.parse(atob(document.getElementById("jsonProperty").innerText));
</script>

Release Notes

  • Added a base64Encode handlebars helper to more safely embed data into stat sheets with {{base64Encode value}} and then decode in javascript with atob(document.getElementById(...).innerText).

This change is Reviewable

@cwisniew cwisniew added this pull request to the merge queue Sep 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Sep 24, 2024
This is intended to pair with the browser atob function
so no base64Decode is provided,
but should be equivalent to the mtscript base64Encode
if data has already been encoded into the token's properties.
@cwisniew cwisniew enabled auto-merge September 26, 2024 08:38
@cwisniew cwisniew added this pull request to the merge queue Sep 26, 2024
Merged via the queue into RPTools:develop with commit b65c884 Sep 26, 2024
4 checks passed
@cwisniew cwisniew added the feature Adding functionality that adds value label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding functionality that adds value
Projects
None yet
2 participants