Commit 7783e069 authored by rikkertkoppes's avatar rikkertkoppes

Added AMD support by checking whether "define" is defined

parent 104949aa
<!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(['src/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>
\ No newline at end of file
This diff is collapsed.
......@@ -523,6 +523,11 @@
// export UriTemplate, when module is present, or pass it to window or global
if (typeof module !== "undefined") {
module.exports = UriTemplate;
}
else if (typeof define !== "undefined") {
define([],function() {
return UriTemplate;
});
}
else if (typeof window !== "undefined") {
window.UriTemplate = UriTemplate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment