Skip to content

Escape charactors in string literals #45

Open
@tuchida

Description

@tuchida

Checklist

  • I have searched the issue list
  • I have tested my example against Shopify Liquid. (This isn't necessary if the actual behavior is a panic, or an error for which IsTemplateError returns false.)

Expected Behavior

{{ "a\"b\\c" }}

output

a"b\c

Actual Behavior

Syntax Error

Detailed Description

ref. #5

The Shopify specification does not allow escaping of characters in string literals.
https://shopify.github.io/liquid/basics/types/#string

Liquid does not convert escape sequences into special characters.

But this is inconvenient for me.

Possible Solution

The proposal makes it escapable when ``.
Shopify/liquid#1174

This my branch uses strconv.Unquote to escape only double-quoted.
master...tuchida:escape-string

In this implementation, it seems that only \' and \" can be escaped.
https://github.com/acstech/liquid/blob/5bcb5c9b2d87dbd09e8a08889477167721e09edf/core/parser.go#L135-L136

If you want to support escaping, you can decide on the specification and I will create a Pull Request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions