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

Line breaks not handled gracefully #120

Open
hotmeteor opened this issue Mar 7, 2023 · 2 comments · May be fixed by #131
Open

Line breaks not handled gracefully #120

hotmeteor opened this issue Mar 7, 2023 · 2 comments · May be fixed by #131
Assignees
Milestone

Comments

@hotmeteor
Copy link

hotmeteor commented Mar 7, 2023

Great plugin, thanks for the work on it!

One UX issue I often hit is the way the Antlers tags are formatted. The biggest issues I hit are:

  • Subsequent tags ignore the line breaks I add, so they all run together
  • Long tags get line-breaks in the middle of them, and then the next tags follow right after

I've included some code below so you can get a sense of what I mean.

{{ nocache }} {{ collection from="training_log" status:is="published" limit="20"
    sort="date:desc" }}
<div class="flex {{ index === 0 ? 'col-span-3 row-span-3 sm:col-span-2 sm:row-span-2' : '' }}">
  <a class="group relative flex" href="{{ url }}">
    {{ if images }} {{ images limit="1" }} <img class="object-cover relative z-0" src="{{
    imagekit :src=" path" n="home_thumbnail" }}" alt=""/> {{ /images }} {{ /if }} {{ if
    index===0 }}
    <div
      class="pointer-events-none absolute bottom-0 right-0 z-20 bg-black bg-opacity-75 px-4 py-2 text-xs font-semibold text-cfhsv-blue group-hover:text-cfhsv-light-blue"
    >
      {{ title }}
    </div>
    {{ /if }}

    <div
      class="pointer-events-none absolute inset-0 z-10 bg-black opacity-20 transition-all duration-200 group-hover:opacity-0"
    ></div>
  </a>
</div>
{{ /collection }} {{ /nocache }}

This obviously isn't a breaking issue but visually it makes it tough to ensure my tags are configured and balanced correctly.

Thanks!

@Konafets
Copy link
Owner

Konafets commented Mar 11, 2023

Hi @hotmeteor,

I found out that the plugin gets confused by the dynamic binding. When you remove the colon from the params and reformat the file, it works as expected.

Dynamic binding is only available for Tags and as for now the plugin operates on a defined set of Tags provided by Statamic and doesn't know Tags coming from Addons like in this case. I need to find a way to make the internal list of Tags dynamic taking all Tags in a project into account.

Thanks for bringing this issue up :-)

Konafets added a commit that referenced this issue Mar 14, 2023
This happened because the lexer got confused by the unknown Tag `imagekit` which comes from an addon. It was lexed and parsed as a variable and the syntax does not allow dynamic bindings for variables, only for Tags. This PR introduces an `T_UNKOWN_TAG` token, which is returned by the lexer when he sees an Identifier which is followed by one or more whitespaces and a colon. 

The formatting issues was just a side effect of the wrong parsing.

Closes #120
@Konafets Konafets linked a pull request Mar 14, 2023 that will close this issue
@Konafets Konafets self-assigned this Mar 15, 2023
@Konafets Konafets added this to the 0.0.6 milestone Mar 15, 2023
Konafets added a commit that referenced this issue Mar 17, 2023
This happened because the lexer got confused by the unknown Tag `imagekit` which comes from an addon. It was lexed and parsed as a variable and the syntax does not allow dynamic bindings for variables, only for Tags. This PR introduces an `T_UNKOWN_TAG` token, which is returned by the lexer when he sees an Identifier which is followed by one or more whitespaces and a colon.

The formatting issues was just a side effect of the wrong parsing.

Closes #120
Konafets added a commit that referenced this issue Mar 19, 2023
This happened because the lexer got confused by the unknown Tag `imagekit` which comes from an addon. It was lexed and parsed as a variable and the syntax does not allow dynamic bindings for variables, only for Tags. This PR introduces an `T_UNKOWN_TAG` token, which is returned by the lexer when he sees an Identifier which is followed by one or more whitespaces and a colon.

The formatting issues was just a side effect of the wrong parsing.

Closes #120
@Konafets
Copy link
Owner

Hi @hotmeteor,

can you provide an example of how the above snippet should be formatted in your opinion?

Thanks in advance!

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

Successfully merging a pull request may close this issue.

2 participants