Commit 98e97e9a authored by fxa's avatar fxa

renamed source, added package.json, fixed number bug

parent 722a84ae
...@@ -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: {firstParam: "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
......
...@@ -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: {
firstParam: "firstValue", first: "1",
secondParam: "secondValue" second: 2
} }
}; };
document.getElementById('id').innerHTML = document.getElementById('id').innerHTML =
......
{
"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
/*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) {
......
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