Slim: what's wrong with these data attributes?

385 views Asked by At

In the following Slim code:

p = f.email_field :email,
    data: {
      toggle: 'popover',
      placement: 'right',
      trigger: 'manual',
      html: 'true'
    },
    autofocus: true,
    placeholder: 'Email address'

I keep getting an error that Expected tag near toggle: 'popover'

What am I doing wrong? Isn't this the correct way to specify data attributes in Slim?

2

There are 2 answers

2
Yury Lebedev On

The indentation is wrong here, because the email field is written in one line with the p tag. This should work:

p
  = f.email_field :email, data: { toggle: 'popover', placement: 'right',
    trigger: 'manual', html: 'true' }, autofocus: true, placeholder: 'Email address'
0
jeffdill2 On

If your actual code is formatted exactly the way you have it here, then the problem could be the hard returns. In Slim, spaces and carriage returns/line feeds matter as far as how the code is interpreted.

I'd try keeping everything on a single line and see if that fixes the problem.