-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathweb.ts
More file actions
32 lines (27 loc) · 916 Bytes
/
web.ts
File metadata and controls
32 lines (27 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Environment, type Loader } from "./core/environment.ts";
import { UrlLoader } from "./loaders/url.ts";
import defaultPlugins from "./plugins/mod.ts";
export interface Options {
includes: URL | Loader;
autoDataVarname?: boolean;
dataVarname?: string;
autoescape?: boolean;
strict?: boolean;
}
export default function (options: Options): Environment {
// Determine the loader based on the includes option
const loader = options.includes instanceof URL
? new UrlLoader(options.includes)
: options.includes;
// Create a new Environment instance with the provided options
const env = new Environment({
loader,
dataVarname: options.dataVarname || "it",
autoescape: options.autoescape ?? false,
autoDataVarname: options.autoDataVarname ?? true,
strict: options.strict ?? false,
});
// Register the default plugins
env.use(defaultPlugins());
return env;
}