forked from fxa/uritemplate-js
/
demo_AMD.html
30 lines (29 loc) · 1.11 KB
/
demo_AMD.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
<!DOCTYPE html>
<html>
<head>
<title>Demo of Usage</title>
<script type="text/javascript" src="require.js"></script>
</head>
<body>
<div id="id"></div>
<script type="text/javascript">
require(['bin/uritemplate.js'], function (UriTemplate) {
"use strict";
var
templateText = "{?query*}",
variables = {
query: {
first: "1",
second: 2
}
};
document.getElementById('id').innerHTML =
"<p>When you have a template of the form</p><p><code>var templateText = \"" + templateText
+ "\";</code></p><p>and params of the form </p><p><code>var variables = " + JSON.stringify(variables)
+ ";</code></p><p>, you can use </p><p><code>UriTemplate.parse(templateText).expand(variables); </code></p><p>to produce </p><p><code>"
+ UriTemplate.parse(templateText).expand(variables)
+ "</code></p><p> Look at the source code of this page!</p>";
});
</script>
</body>
</html>