Bug 41324

Summary: Tidy kohaTable block
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: In Discussion --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: lucas, martin.renvoize, nick, oleonard, paul.derscheid, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 39715    
Bug Blocks: 41323    
Attachments: Bug 41324: Add a xt test
Bug 41324: Tidy some kohaTable blocks - examples
Bug 41324: Tidy modified files

Description Jonathan Druart 2025-11-27 14:20:54 UTC
Bug 39715 removed quotes around DataTables options. We should enforce it with a test to prevent further occurrences.
Comment 1 Jonathan Druart 2025-11-27 14:32:12 UTC
Created attachment 189994 [details] [review]
Bug 41324: Add a xt test

Patch from commit a307855
Comment 2 Jonathan Druart 2025-11-27 14:32:13 UTC
Created attachment 189995 [details] [review]
Bug 41324: Tidy some kohaTable blocks - examples

Commit using --no-verify to ease rebase
Comment 3 Jonathan Druart 2025-11-27 14:32:15 UTC
Created attachment 189996 [details] [review]
Bug 41324: Tidy modified files

Commit the tidiness

perl misc/devel/tidy.pl $(git diff --name-only HEAD~1)
Comment 4 Jonathan Druart 2025-11-27 14:42:17 UTC
Patches for discussion.

One last thing that is not tidy is the script tags from the .tt files.

If script tags have TT tags, the prettier plugin cannot tidy them.

I was trying to provide a solution to prevent regressions for bug 39715. I think this is great, but it will introduce conflicts.

I am happy to continue, but I first need to know if people want that.

The idea is to use JS variables instead of TT variables, and have the assignment in a first script block.

example:

```
<script>
    // This cannot be tidy
    [% IF foo %]
        # do something
        [% ELSE %]
        let foo = 42;
    [% END %]
</script>
```

=>

```
<script>
    // This still cannot be tidy
    let foo = [% foo ? 1 : 0 %];
</script>

<script>
    // But now this will be tidy automatically!
    if ( foo ) {
        # do something
    } else {
        let foo = 42;
    }
</script>
```

On this bug report I will mainly focus on kohaTable, but it may actually impact whole template file. See also bug 41323 for the "remaining ones".