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

Argument replacement happens only once #3

Closed
rshekhtm opened this issue Dec 25, 2022 · 2 comments · Fixed by #4
Closed

Argument replacement happens only once #3

rshekhtm opened this issue Dec 25, 2022 · 2 comments · Fixed by #4
Assignees

Comments

@rshekhtm
Copy link

Hi there - really useful plugin! Running into a small issue, however. I am trying to pass a title argument to an HTML snippet, which needs to it in two place (one in <title> tag, and also in an og:title meta tag), However the plugin currently replaces only the first instance. I could specify two identical title arguments, but that's ugly. I assume this is because replace is doing basic string substitution and per docs, "A regexp with the g flag is the only case where replace() replaces more than once."

@DmitriiNazimov
Copy link

DmitriiNazimov commented Sep 10, 2023

@donnikitos привет!
Спасибо за плагин!
Нашел два бага и исправил локально. Возможно ты найдешь время внести изменения в код библиотеки. Это не займет много времени.

  1. В регулярном выражении attrMatcher присутствует вот такой кусочек (?:s)?, из-за этого если имя передаваемого аттрибута начинает на 's', например 'secondItem', то первая буква s вырезается. Не очень понял зачем это правило, я его удалил и все стало работать ок.
  2. Вторая проблема указано выше Романом и она легко исправляется заменой replace на replaceAll в этой строке data = data.replace({=$${attr[1]}}, attr[2]);

Удачи!

@donnikitos donnikitos self-assigned this Sep 12, 2023
@donnikitos
Copy link
Owner

Thank you guys for submitting and notifying me about the bugs.
The new and fixed version of the plugin is already online and fully working.

@donnikitos donnikitos linked a pull request Sep 12, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants