Skip to content

Commit

Permalink
Merge pull request #75 from Exabyte-io/chore/SOF-7447
Browse files Browse the repository at this point in the history
SOF-7447: remove swig; use nunjucks
  • Loading branch information
k0stik authored Dec 5, 2024
2 parents 56710de + 081a067 commit 8980934
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 108 deletions.
107 changes: 3 additions & 104 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@exabyte-io/periodic-table.js": "2022.6.8-0",
"lodash": "^4.17.21",
"mixwith": "^0.1.1",
"swig": "^1.4.2",
"nunjucks": "^3.2.4",
"underscore": "^1.13.3",
"underscore.string": "^3.3.4"
},
Expand Down
11 changes: 8 additions & 3 deletions src/template.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { allTemplates } from "@exabyte-io/application-flavors.js";
import { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { deepClone } from "@mat3ra/code/dist/js/utils";
import jinja from "swig";
import nunjucks from "nunjucks";
import _ from "underscore";

import { ContextProviderRegistry } from "./context/registry";
Expand Down Expand Up @@ -59,11 +59,16 @@ export class Template extends NamedInMemoryEntity {
let template, rendered;
if (!this.isManuallyChanged) {
try {
template = jinja.compile(this.content);
template = nunjucks.compile(this.content);

// deepClone to pass JSON data without classes
rendered = template && template(this._cleanRenderingContext(renderingContext));
rendered = template.render(this._cleanRenderingContext(renderingContext));
} catch (e) {
console.log(`Template is not compiled: ${e}`);
console.log({
content: this.content,
_cleanRenderingContext: this._cleanRenderingContext(renderingContext),
});
}
this.setRendered(this.isManuallyChanged ? rendered : rendered || this.content);
}
Expand Down

0 comments on commit 8980934

Please sign in to comment.