Skip to content

Commit

Permalink
Merge pull request #246 from Esri/at/adlib-comes-to-hub.js
Browse files Browse the repository at this point in the history
interpolate function
  • Loading branch information
tomwayson authored May 4, 2020
2 parents 65e3850 + 1ffb6d9 commit 1f3156d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
7 changes: 3 additions & 4 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dist/**"
],
"dependencies": {
"adlib": "3.0.5",
"fetch-blob": "github:node-fetch/fetch-blob#master",
"node-fetch": "^2.6.0",
"tslib": "^1.11.1"
Expand All @@ -22,15 +23,13 @@
"@esri/arcgis-rest-auth": "^2.0.0",
"@esri/arcgis-rest-portal": "^2.0.0",
"@esri/arcgis-rest-request": "^2.0.0",
"@esri/arcgis-rest-types": "^2.0.0",
"adlib": "^3.0.3"
"@esri/arcgis-rest-types": "^2.0.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.0.0",
"@esri/arcgis-rest-portal": "^2.0.0",
"@esri/arcgis-rest-request": "^2.0.0",
"@esri/arcgis-rest-types": "^2.0.0",
"adlib": "^3.0.4"
"@esri/arcgis-rest-types": "^2.0.0"
},
"scripts": {
"prepare": "npm run build",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/items/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./delete-prop";
export * from "./fail-safe-update";
export * from "./get-model";
export * from "./get-model-from-options";
export * from "./interpolate";
export * from "./interpolate-item-id";
export * from "./normalize-solution-template-item";
export * from "./replace-item-id";
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/items/interpolate-item-id.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IModelTemplate } from "../types";
import { adlib } from "adlib";
import { interpolate } from "./interpolate";

/**
* Interpolate the item id back into any {{appid}} instances
Expand All @@ -15,5 +15,5 @@ export function interpolateItemId(
return v;
}
};
return adlib(model, settings, transforms);
return interpolate(model, settings, transforms);
}
11 changes: 11 additions & 0 deletions packages/common/src/items/interpolate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { adlib } from "adlib";

/**
* Interpolates handlebars-style placeholders on an object graph
* @param template
* @param settings
* @param transforms
*/
export function interpolate(template: any, settings: any, transforms?: any) {
return adlib(template, settings, transforms);
}
14 changes: 14 additions & 0 deletions packages/common/test/items/interpolate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as adlibModule from "adlib";
import { interpolate } from "../../src";

describe("interpolate", function() {
it("calls adlib", function() {
spyOn(adlibModule, "adlib");

const args = [{ id: "template" }, { id: "settings" }, { id: "transforms" }];

interpolate(args[0], args[1], args[2]);

expect(adlibModule.adlib).toHaveBeenCalledWith(...args);
});
});

0 comments on commit 1f3156d

Please sign in to comment.