Formatting and comments in ECR

While reusing a few pug files I stumbled across this:

This compiles and is rendered:


<%=
{{`pug -p /path/to/includes < #{__DIR__}/index.pug`.stringify}}
%>

But can’t be formatted:

syntax error in 'STDIN:1:1': unexpected token: "<"

But this can be formatted:

# <%=
{{`pug -p /path/to/includes < #{__DIR__}/index.pug`.stringify}}
# %>

But doesn’t compile:

In src/index.ecr:5:1
Error: unexpected token: EOF

P.S.:

I’m doing this:

get "/" do |env|
  render "#{__DIR__}/index.ecr"
end

# index.pug

doctype html
html(lang='zxx')
  head
    include ./head.pug
  body
    include ./body.pug

What am I doing wrong?

The formatter can only handle pure Crystal source code, not ECR.
There is no formatter for ECR.

1 Like

OK, thanks. I’m the formatter now :crazy_face: