1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-30 06:08:57 +01:00

Complete #14 and #15 url{en,de}code filters

This commit is contained in:
Oliver Steele 2017-07-12 12:34:07 -04:00
parent 26bdd09897
commit 2e5cc60c90
3 changed files with 8 additions and 1 deletions

View File

@ -32,7 +32,7 @@ In brief, these aren't implemented:
- The `cycle` and `tablerow` tags
- `{% when a or b %}`
- The `sort_natural`, `url_decode`, and `url_encode` filters
- The `sort_natural` filter
- Loop ranges `{% for a in 1...10 %}`
- Error modes
- Whitespace control

View File

@ -6,6 +6,7 @@ import (
"fmt"
"html"
"math"
"net/url"
"reflect"
"regexp"
"strings"
@ -190,6 +191,8 @@ func AddStandardFilters(fd FilterDictionary) { // nolint: gocyclo
fd.AddFilter("upcase", func(s, suffix string) string {
return strings.ToUpper(s)
})
fd.AddFilter("url_encode", url.QueryEscape)
fd.AddFilter("url_decode", url.QueryUnescape)
// debugging extensions
// inspect is from Jekyll

View File

@ -96,6 +96,10 @@ var filterTests = []struct {
{`" So much room for activities! " | lstrip`, "So much room for activities! "},
{`" So much room for activities! " | rstrip`, " So much room for activities!"},
{`"%27Stop%21%27+said+Fred" | url_decode`, "'Stop!' said Fred"},
{`"john@liquid.com" | url_encode`, "john%40liquid.com"},
{`"Tetsuro Takara" | url_encode`, "Tetsuro+Takara"},
// number filters
{`-17 | abs`, 17},
{`4 | abs`, 4},