thymeleafjs icon indicating copy to clipboard operation
thymeleafjs copied to clipboard

Parameterizable fragment signatures

Open devowhippit opened this issue 1 year ago • 1 comments

I've greatly appreciated this implementation and being able to get to know Thymeleaf. Thank you so much! Noting the following as either a question; am I doing something wrong? or is it possible to support?

I've succeeded with the library using the first argument format option described in parameterizable fragment signatures.

<th:block th:replace="~{path/to/fragment :: fragment(${value1}, ${value2})}">

However, the second parameter option is more desirable but I have not had success using it.

<th:block th:replace="~{path/to/fragment :: fragment(onevar=${value1}, twovar=${value2})}">

Many thanks!

devowhippit avatar Nov 27 '23 16:11 devowhippit

Hey there 👋 Sorry, it's been a while since I really looked into this project and the parsing code, but it looks like the second option isn't implemented hence the inability for you to use it with this library.

For anybody interested, the fragment expression definition is mostly in this block of code: https://github.com/ultraq/thymeleafjs/blob/2f9693736f4faefd6a311559c8352956e2bc6470/source/standard/expressions/ThymeleafExpressionLanguage.js#L168C5-L209 From it, you can see that a fragment expression's "FragmentParameters" are a list of "Expression" rules, nothing in there about like "NameAndExpression" rule which would then be used to read the second syntax.

It doesn't look like there's an existing issue for it (the one saying what syntaxes are supported just says that fragment expressions are supported but doesn't break it down into the various types), so I'll leave this open to track that.

ultraq avatar Nov 29 '23 05:11 ultraq