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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
uritemplate-js
Commits
98e97e9a
Commit
98e97e9a
authored
Jun 10, 2012
by
fxa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed source, added package.json, fixed number bug
parent
722a84ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
README.md
README.md
+6
-6
demo.html
demo.html
+3
-3
package.json
package.json
+12
-0
src/uritemplate.js
src/uritemplate.js
+2
-3
No files found.
README.md
View file @
98e97e9a
...
@@ -12,15 +12,16 @@ It exposes a constructor function UriTemplate with the two methods:
...
@@ -12,15 +12,16 @@ It exposes a constructor function UriTemplate with the two methods:
Requirements
Requirements
------------
------------
You can use uri
-
template.js in any modern browsers (Tested even with IE8 in IE7-Mode), see file demo.html.
You can use uritemplate.js in any modern browsers (Tested even with IE8 in IE7-Mode), see file demo.html.
But you can also use it with node:
But you can also use it with node:
npm install git://www.github.com/fxa/uritemplate-js.git
var
var
UriTemplate = require('./path/to/uritemplate.js'),
UriTemplate = require('uritemplate'),
template,
template;
expanded;
template = UriTemplate.parse('{?query*}';
template = UriTemplate.parse('{?query*}';
template.expand({query: {first
Param: "firstValue", secondParam: "secondValue"
}});
template.expand({query: {first
: 1, second: 2
}});
--> "?firstParam=firstValue&secondParam=secondValue"
--> "?firstParam=firstValue&secondParam=secondValue"
Tests
Tests
...
@@ -34,7 +35,6 @@ Run the tests with
...
@@ -34,7 +35,6 @@ Run the tests with
Comming soon
Comming soon
------------
------------
*
npm support with package.json
*
npm support for npm install
*
npm support for npm install
*
A new method extract(uri), which tries to extract the variables from a given uri
*
A new method extract(uri), which tries to extract the variables from a given uri
...
...
demo.html
View file @
98e97e9a
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<html>
<html>
<head>
<head>
<title>
Demo of Usage
</title>
<title>
Demo of Usage
</title>
<script
type=
"text/javascript"
src=
"src/uri
-
template.js"
></script>
<script
type=
"text/javascript"
src=
"src/uritemplate.js"
></script>
</head>
</head>
<body>
<body>
<div
id=
"id"
></div>
<div
id=
"id"
></div>
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
templateText
=
"
{?query*}
"
,
templateText
=
"
{?query*}
"
,
variables
=
{
variables
=
{
query
:
{
query
:
{
first
Param
:
"
firstValue
"
,
first
:
"
1
"
,
second
Param
:
"
secondValue
"
second
:
2
}
}
};
};
document
.
getElementById
(
'
id
'
).
innerHTML
=
document
.
getElementById
(
'
id
'
).
innerHTML
=
...
...
package.json
0 → 100644
View file @
98e97e9a
{
"name"
:
"uritemplate"
,
"description"
:
"An UriTemplate implementation of rfc 6570"
,
"homepage"
:
"https://www.github.com/fxa/uritemplate-js"
,
"keywords"
:
[
"util"
,
"uri"
,
"template"
,
"rfc6570"
],
"author"
:
"Franz Antesberger"
,
"contributors"
:
[],
"dependencies"
:
[],
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git://github.com/fxa/uritemplate-js.git"
},
"main"
:
"src/uritemplate.js"
,
"version"
:
"0.1.0"
}
\ No newline at end of file
src/uri
-
template.js
→
src/uritemplate.js
View file @
98e97e9a
/*jshint browser:true, bitwise:true, curly:true, devel: true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, nonew:true, undef:true */
/*jshint browser:true, bitwise:true, curly:true, devel: true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, nonew:true, undef:true */
/*global module */
/*global module */
(
function
(
exportCallback
)
{
(
function
(
exportCallback
)
{
"
use strict
"
;
"
use strict
"
;
...
@@ -65,8 +64,8 @@
...
@@ -65,8 +64,8 @@
}
}
return
false
;
return
false
;
}
}
if
(
typeof
object
===
"
string
"
)
{
if
(
typeof
object
===
"
string
"
||
typeof
object
===
"
number
"
||
typeof
object
===
"
boolean
"
)
{
// the empty string is considered as defined
//
even
the empty string is considered as defined
return
true
;
return
true
;
}
}
for
(
propertyName
in
object
)
{
for
(
propertyName
in
object
)
{
...
...
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