From ea6b95db2341f8631196d202c3e287d7f5d1ff21 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Thu, 1 Oct 2009 01:52:59 +0200 Subject: [PATCH] initial commit --- package.json | 18 ++++++++++++++++++ post-receive | 27 +++++++++++++++++++++++++++ tests/all-tests.js | 4 ++++ tests/json-template-tests.js | 23 +++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 package.json create mode 100644 post-receive create mode 100644 tests/all-tests.js create mode 100644 tests/json-template-tests.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..2e269f7 --- /dev/null +++ b/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": [ + ] +} \ No newline at end of file diff --git a/post-receive b/post-receive new file mode 100644 index 0000000..a394c6c --- /dev/null +++ b/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 +# +# 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>)" -m "2" -) +fi; \ No newline at end of file diff --git a/tests/all-tests.js b/tests/all-tests.js new file mode 100644 index 0000000..f4c7106 --- /dev/null +++ b/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)); + diff --git a/tests/json-template-tests.js b/tests/json-template-tests.js new file mode 100644 index 0000000..b9f0c39 --- /dev/null +++ b/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' + + '

Welcome to FooBar!

' + + ''; + assert.isEqual(new Template(src).expand(data), result); +}; + +if (module.id == require.main) + require('os').exit(require('test/runner').run(exports)); +