Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Sep 30, 2009
0 parents commit ea6b95d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions package.json
@@ -0,0 +1,18 @@
{
"name": "json-template",
"description": "Minimal but powerful templating language implemented in multiple languages.",
"keywords": [
"template",
"json"
],
"author": "andychup (http://code.google.com/u/andychup/)",
"contributors": [
"Irakli Gozalishvili (http://rfobic.wordpress.com/)"
],
"lib": "lib",
"license": [
"Apache License 2.0",
],
"dependencies": [
]
}
27 changes: 27 additions & 0 deletions post-receive
@@ -0,0 +1,27 @@
#!/bin/sh
#
# An example hook script for the post-receive event
#
# This script is run after receive-pack has accepted a pack and the
# repository has been updated. It is passed arguments in through stdin
# in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for an sample, or uncomment the next line (on debian)
#


#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
ref=$(<.git/HEAD)
branch=${ref##ref: refs/heads/}

if [ $branch == "hg" ]; then
origin=$(pwd)
root=$origin; while [ ! -d "$root/.git" ]; do root="$root/.."; done
file=$root/lib/json-template/json-template.js
wget -qO- http://json-template.googlecode.com/hg/javascript/json-template.js > $file;
git add $file
git commit -m $(wget -qO- http://code.google.com/feeds/p/json-template/hgchanges/basic | grep -E "(<title>|<title>)" -m "2" -)
fi;
4 changes: 4 additions & 0 deletions tests/all-tests.js
@@ -0,0 +1,4 @@
exports["test - json-template"] = require("./json-template-tests");
if (require.main === module.id)
require("os").exit(require("test/runner").run(exports));

23 changes: 23 additions & 0 deletions tests/json-template-tests.js
@@ -0,0 +1,23 @@
var assert = require("test/assert"),
Template = require("json-template/json-template").Template;

exports["test - sample"] = function() {
var src = '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:st="http://hyperstruct.net/seethrough#js">'
+ '<head><title st:content="site.title"/></head>'
+ '<body><h1>Welcome to <span st:replace="site.title"/>!</h1></body>'
+ '</html>';
var data = {
site: {
title: 'FooBar'
}
};
var result = '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:st="http://hyperstruct.net/seethrough#js">'
+ '<head><title>FooBar</title></head>'
+ '<body><h1>Welcome to FooBar!</h1></body>'
+ '</html>';
assert.isEqual(new Template(src).expand(data), result);
};

if (module.id == require.main)
require('os').exit(require('test/runner').run(exports));

0 comments on commit ea6b95d

Please sign in to comment.