Function Updated 23 Oct 2026
urlEncode(text)
URL-encodes text the way HTML forms do: a space becomes + and other unsafe characters become %xx. encodeURIComponent() encodes the standard JavaScript way instead (a space becomes %20) — use it for URL paths and query values.
Parameters
textstringrequiredText to encode.
Returns
An encoded string.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
<!-- Output: 1+2+3 -->
#docly.urlEncode("1 2 3")#The template above produces this output:
<!-- Output: 1+2+3 -->
1+2+3