-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathklipse_in_frame.html
64 lines (40 loc) · 1.32 KB
/
klipse_in_frame.html
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title> KLIPSE demo</title>
<link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css">
<link rel="stylesheet" type="text/css" href="https://viebel.github.io/klipse/examples/main.css">
</head>
<body class="container">
<h1> Javascript isolated snippets </h1>
In order to have secured snippets, each <code>klipse-snippet</code> element is embedded into an iframe.
<br>
This approach supports the following features:
<br/>
<h5>Usual data manipulation stuff:</h5>
<klipse-snippet data-language="javascript">
[1,2,3].map((x) => x +1)
</klipse-snippet>
<h5> sandboxed dom manipulation :) </h5>
<br>
<klipse-snippet data-language="javascript">
klipse_container.innerHTML = "hello <b>dev.to</b>";
1 + 2;
</klipse-snippet>
<h5> The sandbox is secured: you cannot access the document cookies </h5>
<klipse-snippet data-language="javascript">
document.cookie
</klipse-snippet>
<h5> But you cannot share code or data between snippets :( </h5>
<klipse-snippet data-language="javascript">
foo = (name) => `Hello ${name}`
foo("Klipse")
</klipse-snippet>
<klipse-snippet data-language="javascript">
foo("Javascript")
</klipse-snippet>
<script src="./klipse_reveal.js">
</script>
</body>
</html>