You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 9, 2025. It is now read-only.
// After 2000ms will render <div>Failed to load</div>
247
247
```
248
+
249
+
### CSP Trusted Types
250
+
251
+
You can call `TemplateResult.setCSPTrustedTypesPolicy(policy: TrustedTypePolicy | Promise<TrustedTypePolicy> | null)` from JavaScript to set a [CSP trusted types policy](https://web.dev/trusted-types/), which can perform (synchronous) filtering or rejection of the rendered template:
252
+
253
+
```ts
254
+
import {TemplateResult} from "@github/jtml";
255
+
import DOMPurify from "dompurify"; // Using https://github.com/cure53/DOMPurify
256
+
257
+
// This policy removes all HTML markup except links.
- Only a single policy can be set, shared by all `render` and `unsafeHTML` calls.
273
+
- You should call `TemplateResult.setCSPTrustedTypesPolicy()` ahead of any other call of `@github/jtml` in your code.
274
+
- Not all browsers [support the trusted types API in JavaScript](https://caniuse.com/mdn-api_trustedtypes). You may want to use the [recommended tinyfill](https://github.com/w3c/trusted-types#tinyfill) to construct a policy without causing issues in other browsers.
0 commit comments