CMS Development

Hubmonks
メンバー

How to encode and decode string using HUBL

解決

How to encode and decode string using HubL same as atob() and btoa() fucntion does in Javascript. 

0 いいね!
1件の承認済みベストアンサー
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How to encode and decode string using HUBL

解決

@Hubmonks I don't see anything in the HubSpot HubL Documentation, however, you could try the following filter which works in certain Jinja environments (hubl was originally based on jinja):

{{ encoded_string|b64decode }}
{{ decoded_string|b64encode }}

It most likely won't work but it's worth a shot. Otherwise, you could print the HubL string into a script tag and use the js function on the client side.

Stefen Phelps, Community Champion, Kelp Web Developer

元の投稿で解決策を見る

4件の返信
SStrachan1
参加者

How to encode and decode string using HUBL

解決

@stefen @piersg 

I am trying to decode a URL and getting this error. Any ideas on what's wrong?

input byte array has wrong 4-byte ending unit

{% set encoded_url = request.query %}
<h5>encoded: {{ encoded_url }}</h5>

{% set decoded_url = encoded_url|b64decode %}
<h5>decoded: {{ decoded_url }}</h5>

 

0 いいね!
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How to encode and decode string using HUBL

解決

@Hubmonks I don't see anything in the HubSpot HubL Documentation, however, you could try the following filter which works in certain Jinja environments (hubl was originally based on jinja):

{{ encoded_string|b64decode }}
{{ decoded_string|b64encode }}

It most likely won't work but it's worth a shot. Otherwise, you could print the HubL string into a script tag and use the js function on the client side.

Stefen Phelps, Community Champion, Kelp Web Developer
piersg
キーアドバイザー

How to encode and decode string using HUBL

解決

For this record this does work, thanks @stefen 👍

0 いいね!
stefen
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

How to encode and decode string using HUBL

解決

nice, good to know!

Stefen Phelps, Community Champion, Kelp Web Developer