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

Repeated use of an attribute #66

Closed
finanalyst opened this issue Jan 10, 2022 · 2 comments
Closed

Repeated use of an attribute #66

finanalyst opened this issue Jan 10, 2022 · 2 comments

Comments

@finanalyst
Copy link

finanalyst commented Jan 10, 2022

I'm trying to match begin and end tags for headers, eg./
<h2>...</h2>
where the level (eg.2) is in an attribute.

The following template fails:

<h<?.level><.level></?>>
<.text>
</h<?.level><.level></?>>

The problem appears to bre related to <.level> being called repeatedly.
The full error message is as follows:

An operation first awaited:
  in sub compile-dir at /home/richard/.raku/sources/8727B7CE66F46D2210CCD9CE826288AA463FF9AC (Cro::WebApp::Template) line 108
  in sub template-location at /home/richard/.raku/sources/8727B7CE66F46D2210CCD9CE826288AA463FF9AC (Cro::WebApp::Template) line 102
  in block <unit> at do-templ.raku line 5

Died with the exception:
    Template parse failed: confused at line 3 near '</?>>'
      in method panic at /home/richard/.raku/sources/8262DE42E320C5C27BF8F4B9C4B9D431C700EDBE (Cro::WebApp::Template::Parser) line 425
      in regex TOP at /home/richard/.raku/sources/8262DE42E320C5C27BF8F4B9C4B9D431C700EDBE (Cro::WebApp::Template::Parser) line 21
      in sub load-template at /home/richard/.raku/sources/5B4AC652518EF031FD5F107F81DAA12BAB60A86B (Cro::WebApp::Template::Repository) line 134
      in code  at /home/richard/.raku/sources/5B4AC652518EF031FD5F107F81DAA12BAB60A86B (Cro::WebApp::Template::Repository) line 76
@jnthn
Copy link
Member

jnthn commented Jan 10, 2022

It was never really intended that one could interpolate tag names. It does - far more by accident than design - work out for opening tags, however I suspect that will cease to work with the most obvious implementation of #44. For closing tags we simply never try to parse inside of them and thus end up confused.

I've mixed feelings about supporting this; I really want structured tag support as requested in the referenced issue, but supporting interpolating into HTML tag names will significantly complicate it.

@finanalyst
Copy link
Author

FWIW, I found a workaround using a sub.
For the example I was needing:

<:sub heading($level=1,:$close=False)>
<?$close>/</?>h<$level></:>

<<&heading(.level)> id="<.target>">
<a href="#<.top>" class="u" title="go to top of document">
<.text>
</a>
<<&heading(.level,:close)>>

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