Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uritemplate-js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
uritemplate-js
Commits
7783e069
Commit
7783e069
authored
Aug 22, 2012
by
rikkertkoppes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added AMD support by checking whether "define" is defined
parent
104949aa
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
0 deletions
+66
-0
demo_AMD.html
demo_AMD.html
+30
-0
require.js
require.js
+31
-0
src/uritemplate.js
src/uritemplate.js
+5
-0
No files found.
demo_AMD.html
0 → 100644
View file @
7783e069
<!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
require.js
0 → 100644
View file @
7783e069
This diff is collapsed.
Click to expand it.
src/uritemplate.js
View file @
7783e069
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment