NAME
Koha::QA::Tidy::TT - Centralized Template Toolkit tidiness checking using prettier
SYNOPSIS
use Koha::QA::Tidy::TT;
# With a file
my $checker = Koha::QA::Tidy::TT->new({file => $file, prettierrc => $prettierrc});
# Or with content directly
my $checker = Koha::QA::Tidy::TT->new({content => $file_content, prettierrc => $prettierrc});
my $is_tidy = $checker->check;
my @errors = $checker->errors;
# Return the tidy version
my $success = $checker->fix;
DESCRIPTION
This module provides centralized Template Toolkit tidiness checking and formatting using prettier with the @koha-community/prettier-plugin-template-toolkit.
METHODS
new
my $checker = Koha::QA::Tidy::TT->new({file => $file, prettierrc => $prettierrc});
Creates a new Tidy::TT instance.
Arguments: - prettierrc: Optional path to .prettierrc.js file (default: .prettierrc.js)
check
my $is_tidy = $checker->check;
Checks if a Template Toolkit file is tidy by comparing the original content with the output from prettier.
errors
my @errors = $checker->errors;
Returns array of error hashrefs, each with: - error: the error type (tidy_tt, no_prettierrc, tidy_tt_empty_output, tidy_tt_prettier_failed)
fix
my $output = $checker->fix;
Runs prettier on the file and returns the tidied content without modifying the file.
Returns: - String with tidied content on success - undef on failure
AUTHORS
Jonathan Druart <jonathan.druart@bugs.koha-community.org>
COPYRIGHT
Copyright 2026 Koha Development Team
LICENSE
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.