Skip to content

Commit 679b627

Browse files
authored
Merge pull request #568 from ProfoundLogic/change-hogan-dependency
switching to @profoundlogic/hogan
2 parents 9aa780e + 1461337 commit 679b627

File tree

6 files changed

+108
-53
lines changed

6 files changed

+108
-53
lines changed

package-lock.json

Lines changed: 35 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
"main": "./lib/diff2html.js",
6969
"module": "./lib-esm/diff2html.js",
7070
"types": "./lib/diff2html.d.ts",
71+
"ts-node": {
72+
"compilerOptions": {
73+
"module": "commonjs",
74+
"typeRoots": [
75+
"./node_modules/@types",
76+
"./typings"
77+
]
78+
}
79+
},
7180
"lint-staged": {
7281
"**/*.+(js|jsx|ts|tsx|json)": [
7382
"prettier --write",
@@ -82,7 +91,7 @@
8291
},
8392
"dependencies": {
8493
"diff": "^7.0.0",
85-
"hogan.js": "3.0.2"
94+
"@profoundlogic/hogan": "^3.0.4"
8695
},
8796
"optionalDependencies": {
8897
"highlight.js": "11.9.0"

scripts/hulk.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
* limitations under the License.
1414
*/
1515

16+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
17+
/// <reference path="../typings/profoundlogic__hogan.d.ts" />
18+
1619
import * as path from 'path';
1720
import * as fs from 'fs';
1821

19-
import * as hogan from 'hogan.js';
22+
import * as hogan from '@profoundlogic/hogan';
2023
import nopt from 'nopt';
2124
import * as mkderp from 'mkdirp';
2225

@@ -118,7 +121,7 @@ function wrap(file: string, name: string, openedFile: string): string {
118121
case 'amd':
119122
return `define(${
120123
!options.outputdir ? `"${path.join(path.dirname(file), name)}", ` : ''
121-
}["hogan.js"], function(Hogan) { return ${hoganTemplateString}; });`;
124+
}["@profoundlogic/hogan"], function(Hogan) { return ${hoganTemplateString}; });`;
122125

123126
case 'node':
124127
// If we have a template per file the export will expose the template directly
@@ -139,12 +142,12 @@ function prepareOutput(content: string): string {
139142
case 'node':
140143
return `(function() {
141144
if (!!!global.${variableName}) global.${variableName} = {};
142-
var Hogan = require("hogan.js");
145+
var Hogan = require("@profoundlogic/hogan);
143146
${content}
144147
${!options.outputdir ? `module.exports = global.${variableName};\n` : ''})();`;
145148

146149
case 'ts':
147-
return `import * as Hogan from "hogan.js";
150+
return `import * as Hogan from "@profoundlogic/hogan";
148151
type CompiledTemplates = { [name: string]: Hogan.Template };
149152
export const ${variableName}: CompiledTemplates = {};
150153
${content}`;

src/hoganjs-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Hogan from 'hogan.js';
1+
import * as Hogan from '@profoundlogic/hogan';
22

33
import { defaultTemplates } from './diff2html-templates';
44

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["src/**/*", "typings/**/*"],
2+
"include": ["src/**/*", "typings/**/*", "scripts/**/*"],
33
"exclude": ["node_modules", "src/__tests__/**"],
44
"compilerOptions": {
55
"outDir": "bundles-out",
@@ -32,6 +32,7 @@
3232
"preserveConstEnums": true,
3333
"alwaysStrict": true,
3434
"noImplicitAny": true,
35-
"noImplicitThis": true
35+
"noImplicitThis": true,
36+
"typeRoots": ["./node_modules/@types", "./typings"]
3637
}
3738
}

typings/profoundlogic__hogan.d.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
declare module '@profoundlogic/hogan' {
2+
export interface Context {
3+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4+
[key: string]: any;
5+
}
6+
7+
export interface SectionTags {
8+
o: string;
9+
c: string;
10+
}
11+
12+
export interface HoganOptions {
13+
asString?: boolean | undefined;
14+
sectionTags?: readonly SectionTags[] | undefined;
15+
delimiters?: string | undefined;
16+
disableLambda?: boolean | undefined;
17+
}
18+
19+
export interface Token {
20+
tag: string;
21+
otag?: string | undefined;
22+
ctag?: string | undefined;
23+
i?: number | undefined;
24+
n?: string | undefined;
25+
text?: string | undefined;
26+
}
27+
28+
export interface Leaf extends Token {
29+
end: number;
30+
nodes: Token[];
31+
}
32+
33+
export type Tree = Leaf[];
34+
35+
export interface Partials {
36+
[symbol: string]: HoganTemplate;
37+
}
38+
39+
export class HoganTemplate {
40+
render(context: Context, partials?: Partials, indent?: string): string;
41+
}
42+
43+
export { HoganTemplate as Template, HoganTemplate as template };
44+
45+
export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate;
46+
export function compile(text: string, options?: HoganOptions & { asString: true }): string;
47+
export function compile(text: string, options?: HoganOptions): HoganTemplate | string;
48+
49+
export function scan(text: string, delimiters?: string): Token[];
50+
51+
export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree;
52+
}

0 commit comments

Comments
 (0)