Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space added to quotes in attribute (with replaceQuote disabled) #71

Open
jweckschmied opened this issue Dec 6, 2022 · 2 comments
Open

Comments

@jweckschmied
Copy link

jweckschmied commented Dec 6, 2022

So I've got this div right here:

<div role="article" aria-roledescription="email" aria-label='{{ translate "subject" }}' lang="en">

Note that I've changed the default posthtml delimiters to be [[ and ]] so they don't clash with the templating syntax we use down the line. replaceQuote is set to false.

What I expect is to get exactly the same thing after posthtml (except for it maybe changing the outer quotes, I don't really care about that):

<div role="article" aria-roledescription="email" aria-label="{{ translate "subject" }}" lang="en">

However, what I actually get is this:

<div role="article" aria-roledescription="email" aria-label="{{translate " subject"}}" lang="en">

Notice the additional space after the quote, because it seems like posthtml considers the second quote to be the closing tag for the aria-label. Unfortunately, this breaks the template during further processing. I've tried everything, from changing the quoteStyle to adding a custom directive { name: ' translate "subject"', start: '{{', end: '}}' }. But nothing has worked so far.

I know this is quite an odd special case, but I'd very much appreciate some help with this.

@cossssmin
Copy link
Member

Looks like you're using this in Maizzle? Any reason you can't use single quotes around subject?

This works fine without even having to change the delimiters - just ignore the expression and use single quotes:

<div aria-label="@{{ translate 'subject' }}">

@jweckschmied
Copy link
Author

Yes, I’m using maizzle.
I wish I could use single quotes, but unfortunately the go html/template syntax (where these templates are then filled with content) only accepts double quotes…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants