SublimeHyperClick
SublimeHyperClick copied to clipboard
match Twig include tags with extra parameters
Ensures matches for just the file for tag style with extra parameters:
{% include 'template.html' with {'foo': 'bar'} %}
https://twig.symfony.com/doc/3.x/tags/include.html
Previously the regex would match from the first quote all the way to the last quote, but it shouldn't include the extra object with parameters.
This PR is fine for sure.
I am using https://github.com/jfcherng-sublime/ST-my-settings/blob/dc509e19387cfa9ad827e78ee3b4dbb7e2f83791/Packages/User/HyperClick.sublime-settings#L80-L86 (although ' can be used in filename actually)
I think we don't have to match the rest of the string right after we have found the filename (the leading {% is quite a strong assertion). Anyway, merging them gives better performance and maintainability(?).
Hm, yours has less repetition for sure, but for some of my test cases it doesn't work. You seem to have dropped the {{ include('file', {params}) }} form.
<div id="regular-event">
<section class="eticket">
{{ include('Etickets/_eticket_header.html.twig', {
event : event,
production : production,
type: 'regular'
}) }}
<div class="eticket-body">
{% for ticket in tickets %}
{{ include('Etickets/_eticket_body.html.twig', { ticket: ticket, type: 'regular'}) }}
{% endfor %}
</div>
</section>
</div>
But yeah, you don't have to match all the way to the end of the statement. The opening of the statement and the initial include, etc., keyword are good indicators of the intent.
Edit: added example.
@aziz are you still maintaining this package? I would like to help out.
I cannot add collaborators but I'd vouch for @braver and @jfcherng
@cristianl thanks for merging! Can you tag a release with the latest changes?
@aziz to consider: we could also move the repo to the SublimeText org where multiple experienced package developers maintain lots of packages.
2.6.0 is now up. Sorry for the long delay.