demo.html 1.12 KB
Newer Older
fxa's avatar
fxa committed
1 2 3 4
<!DOCTYPE html>
<html>
<head>
    <title>Demo of Usage</title>
fxa's avatar
fxa committed
5
    <script type="text/javascript" src="bin/uritemplate.js"></script>
fxa's avatar
fxa committed
6 7
</head>
<body>
fxa's avatar
fxa committed
8
<div id="id"></div>
fxa's avatar
fxa committed
9 10 11 12
<script type="text/javascript">
    (function () {
        "use strict";
        var
fxa's avatar
fxa committed
13 14 15 16 17 18
                templateText = "{?query*}",
                variables = {
                    query: {
                        first: "1",
                        second: 2
                    }
19 20
                },
                expanded = UriTemplate.parse(templateText).expand(variables);
fxa's avatar
fxa committed
21 22
        document.getElementById('id').innerHTML =
                "<p>When you have a template of the form</p><p><code>var templateText = \"" + templateText
23
                        + "\";</code></p><p>and params of the form </p><p><code>var variables = {query: {first: \"1\", second: 2}}"
fxa's avatar
fxa committed
24
                        + ";</code></p><p>, you can use </p><p><code>UriTemplate.parse(templateText).expand(variables); </code></p><p>to produce </p><p><code>"
25
                        + expanded
fxa's avatar
fxa committed
26
                        + "</code></p><p> Look at the source code of this page!</p>";
fxa's avatar
fxa committed
27 28 29 30 31
    }());
</script>

</body>
</html>