feat: add label configuration fields to barcode templates and implement zero-padding support in variable replacement
Build and Push Multi-Platform Images / build-and-push (push) Successful in 27s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 27s
This commit is contained in:
@@ -6,7 +6,17 @@ import { BarcodeTemplate } from '../database/entities/barcode-template.entity';
|
||||
import { LabelRendererService } from './label-renderer.service';
|
||||
|
||||
function applyVars(template: string, vars: Record<string, string>): string {
|
||||
return template.replace(/\{([^}]+)\}/g, (_, key) => vars[key] ?? '');
|
||||
return template.replace(/\{([^}]+)\}/g, (_, key: string) => {
|
||||
const colonIdx = key.indexOf(':');
|
||||
if (colonIdx !== -1) {
|
||||
const varName = key.slice(0, colonIdx);
|
||||
const width = parseInt(key.slice(colonIdx + 1), 10);
|
||||
if (!isNaN(width) && varName in vars) {
|
||||
return vars[varName].padStart(width, '0');
|
||||
}
|
||||
}
|
||||
return vars[key] ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
function lockExpiry(): Date {
|
||||
|
||||
Reference in New Issue
Block a user