RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.
http://rptools.net
GNU Affero General Public License v3.0
787 stars 259 forks source link

Add base64Encode handlebars helper #4925

Closed fishface60 closed 2 days ago

fishface60 commented 1 week ago

Identify the Bug or Feature request

closes https://github.com/RPTools/maptool/issues/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


This change is Reviewable