Skip to content

Commit

Permalink
Provided fix for using the wrong template whenever the name of the cu…
Browse files Browse the repository at this point in the history
…stom template and default template are identical
  • Loading branch information
KristofVDB1 committed Sep 23, 2024
1 parent 9f985bf commit e7f187b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions packages/oslo-generator-html/lib/HtmlGenerationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import { SpecificationType } from './utils/specificationTypeEnum';
export class HtmlGenerationService implements IService {
public readonly logger: Logger;
public readonly configuration: HtmlGenerationServiceConfiguration;
public dirs: string[] = [resolve(`${__dirname}/templates`)];

public constructor(
@inject(ServiceIdentifier.Logger) logger: Logger,
@inject(ServiceIdentifier.Configuration)
config: HtmlGenerationServiceConfiguration,
config: HtmlGenerationServiceConfiguration
) {
this.logger = logger;
this.configuration = config;
}

public async init(): Promise<void> {
const dirs: string[] = [resolve(`${__dirname}/templates`)];
if (this.configuration.templates) {
let templatesPath = this.configuration.templates;

Expand All @@ -32,25 +32,29 @@ export class HtmlGenerationService implements IService {
}

const customTemplatesDir: string = resolve(templatesPath);
dirs.push(customTemplatesDir);
this.dirs.push(customTemplatesDir);
}

const env = nj.configure(dirs);
const env = nj.configure(this.dirs);
env.addGlobal('getAnchorTag', this.getAnchorTag);
}

public async run(): Promise<void> {
let indexPath: string = '';
const [config, stakeholders, metadata] = await Promise.all([
this.readConfigFile(this.configuration.input),
this.readConfigFile(this.configuration.stakeholders),
this.readConfigFile(this.configuration.metadata),
]);

const indexPath =
this.configuration.rootTemplate ||
(this.configuration.specificationType === SpecificationType.Vocabulary
? 'voc2.j2'
: 'ap2.j2');
if (this.configuration.templates && this.configuration.rootTemplate) {
indexPath = `${this.dirs[1]}/${this.configuration.rootTemplate}`;
} else {
indexPath =
this.configuration.specificationType === SpecificationType.Vocabulary
? `${this.dirs[0]}/voc2.j2`
: `${this.dirs[0]}/ap2.j2`;
}

let data: any = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/oslo-generator-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/html-generator",
"version": "0.0.18-alpha.0",
"version": "0.0.19-alpha.0",
"description": "Generates an HTML file using an OSLO webuniversum config",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-html#readme",
Expand Down

0 comments on commit e7f187b

Please sign in to comment.