{"record":{"id":"880d98b3e8c63157","repo":"karatelabs/karate","slug":"karate-markup-does-not-support-param-lists-in-th-fragment-880d98","errorCode":null,"errorMessage":"karate-markup does not support param lists in th:fragment signatures.\\n  Found    th:fragment=\"${value}\"\\n  Change   th:fragment=\"name(p1, p2)\"   ➜   th:fragment=\"name\"\\n  Pass values via th:with at the call site; ...","messagePattern":"karate-markup does not support param lists in th:fragment signatures\\.\\\\n  Found    th:fragment=\"(.+?)\"\\\\n  Change   th:fragment=\"name\\(p1, p2\\)\"   ➜   th:fragment=\"name\"\\\\n  Pass values via th:with at the call site; \\.\\.\\.","errorType":"exception","errorClass":"TemplateProcessingException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/markup/KaFragmentProcessor.java","lineNumber":67,"sourceCode":" * check.\n */\nfinal class KaFragmentProcessor extends AbstractElementTagProcessor {\n\n    KaFragmentProcessor(TemplateMode templateMode, String dialectPrefix) {\n        super(templateMode, dialectPrefix, null, false,\n                StandardFragmentTagProcessor.ATTR_NAME, true,\n                StandardFragmentTagProcessor.PRECEDENCE);\n    }\n\n    @Override\n    protected void doProcess(\n            ITemplateContext context,\n            IProcessableElementTag tag,\n            IElementTagStructureHandler structureHandler) {\n        AttributeName attributeName = getMatchingAttributeName().getMatchingAttributeName();\n        String value = tag.getAttributeValue(attributeName);\n        if (value != null && value.indexOf('(') >= 0) {\n            throw new TemplateProcessingException(\n                    FragmentSupport.signatureMessage(value, null, null));\n        }\n        // Marker attribute — strip it now that the validation is done.\n        structureHandler.removeAttribute(attributeName);\n    }\n\n}\n","sourceCodeStart":49,"sourceCodeEnd":75,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/markup/KaFragmentProcessor.java#L49-L75","documentation":"karate-markup does not implement parameterized fragment signatures. When a `th:fragment` attribute value contains a parenthesized parameter list (e.g. `th:fragment=\"card(title, items)\"`), KaFragmentProcessor rejects it via TemplateProcessingException carrying FragmentSupport.signatureMessage, which explains the unsupported syntax and the workaround: declare the fragment without parameters and pass values via `th:with` at the call site.","triggerScenarios":"Declaring a fragment as `th:fragment=\"name(p1, p2)\"` — i.e. any th:fragment value containing `(` — then rendering a template that includes it.","commonSituations":"Migrating templates from full Thymeleaf (which supports `th:fragment=\"name(p1,p2)\"` signatures and `th:replace=\"~{::frag(...)}\"` calls) into Karate markup; copying standard Thymeleaf layout examples from tutorials or the Thymeleaf docs.","solutions":["Change the declaration from `th:fragment=\"name(p1, p2)\"` to just `th:fragment=\"name\"`.","At the call site, pass the values via `th:with=\"p1=..., p2=...\"` instead of signature arguments.","Inside the fragment, read the values through `context.get('p1', defaultValue)` for optional fragment params.","Search your templates for `th:fragment=\"` occurrences containing `(` and fix all of them — the error is raised per-fragment on render."],"exampleFix":"// before\n<div th:fragment=\"card(title, body)\">...</div>\n<div th:replace=\"~{frag :: card('Hi', 'Text')}\"></div>\n\n// after\n<div th:fragment=\"card\">...</div>\n<div th:replace=\"~{frag :: card}\" th:with=\"title='Hi', body='Text'\"></div>","handlingStrategy":"validation","validationCode":"// Fail fast in tests if any fragment declares params\nFiles.walk(templatesDir)\n    .filter(p -> p.toString().endsWith(\".html\"))\n    .forEach(p -> {\n        String s = Files.readString(p);\n        Matcher m = Pattern.compile(\"th:fragment=\\\"([^\\\"]*\\\\()[^\\\"]*\\\"\").matcher(s);\n        if (m.find()) throw new IllegalStateException(\"Param list in th:fragment in \" + p);\n    });","typeGuard":null,"tryCatchPattern":"try {\n    render(template);\n} catch (TemplateProcessingException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"param lists\")) {\n        log.error(\"Fragment uses unsupported signature: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Never write th:fragment=\"name(p1,p2)\" — declare just the name","Pass fragment values with th:with at the call site","Read optional params inside fragments via context.get('p1', default)","When migrating from standard Thymeleaf, audit fragment signatures first"],"tags":["markup","thymeleaf","fragments","unsupported-feature"],"backgroundTag":"unsupported-operation","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}