demo_AMD.html 1.11 KB
Newer Older
1 2 3 4 5 6 7
<!DOCTYPE html>
<html>
<head>
    <title>Demo of Usage</title>
    <script type="text/javascript" src="require.js"></script>
</head>
<body>
fxa's avatar
fxa committed
8
<div id="id"></div>
9
<script type="text/javascript">
fxa's avatar
fxa committed
10
    require(['bin/uritemplate.js'], function (UriTemplate) {
11 12
        "use strict";
        var
fxa's avatar
fxa committed
13 14 15 16 17 18 19
                templateText = "{?query*}",
                variables = {
                    query: {
                        first: "1",
                        second: 2
                    }
                };
20 21
        document.getElementById('id').innerHTML =
                "<p>When you have a template of the form</p><p><code>var templateText = \"" + templateText
fxa's avatar
fxa committed
22 23 24 25
                        + "\";</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>";
26 27 28 29 30
    });
</script>

</body>
</html>