-json=json2
--runtime=standard
--runtime=lite Same as --ajax=none --json=none
--runtime=jquery Same as --ajax=jquery --json=none
--runtime=yui Same as --ajax=yui --json=
ajax=gregory --json=json2
--json By itself, equivalent to --json=json2
--json=json2 Include http://www.json.org/json2.js for parsing/stringifying
--json=yui U
se YUI: YAHOO.lang.JSON (requires external YUI)
--json=none Doesn't provide any JSON functionality except a warning
--ajax By itself, equivalent to --ajax=xhr
--a
json_json2 {
<<'...';
[% INCLUDE "js/json-json2.compact.js" %]
...
}
sub json_json2_internal {
<<'...';
;(function(){
var JSON;
[% INCLUDE "js/json2.compact.js" %]
[% INCLUDE "js/json-json
-internal.compact.js" %]
}());
...
}
sub json_yui {
<<'...';
[% INCLUDE "js/json-yui.compact.js" %]
...
}
sub json2 {
<<'...';
[% INCLUDE "js/json2.compact.js" %]
...
}
sub xhr_gregory {
METHODS
head2 kernel
head2 ajax_jquery
head2 ajax_xhr
head2 ajax_yui
head2 json_json2
head2 json_yui
head2 json2
head2 xhr_gregory
head2 xhr_ilinsky
head2 xxx
=head1 COPYRIGHT
Copyright (
urp;
if ($mode eq 'perl') {
require JSON;
my $json = JSON->new(); #pretty => 1, delimiter => 1);
$context = $json->objToJson(eval $content );
} else {
#assume i
else if (typeof data == 'string') {
// Jemplate.Ajax.get(data, function(r) { proc(Jemplate.JSON.parse(r)) });
var url = data;
Jemplate.Ajax.processGet(url, function(data) { proc
e.JSON = {
parse: function(decodeValue) {
throw("This is a Jemplate.JSON.parse " + stubExplanation);
},
stringify: function(encodeValue) {
throw("This is a Jemplate.JSON.
ry.get(url, null, callback);
},
processGet: function(url, processor) {
jQuery.getJSON(url, null, processor);
},
post: function(url, data, callback) {
jQuery.post(url,
}
sub json_json2 {
<<'...';
[% INCLUDE "js/json-json2.js" %]
...
}
sub json_json2_internal {
<<'...';
;(function(){
var JSON;
[% INCLUDE "js/json2.js" %]
[% INCLUDE "js/json-json2-intern
al.js" %]
}());
...
}
sub json_yui {
<<'...';
[% INCLUDE "js/json-yui.js" %]
...
}
sub json2 {
<<'...';
[% INCLUDE "js/json2.js" %]
...
}
sub xhr_gregory {
<<'...';
[% INCLUDE "js/xhr-
METHODS
head2 kernel
head2 ajax_jquery
head2 ajax_xhr
head2 ajax_yui
head2 json_json2
head2 json_yui
head2 json2
head2 xhr_gregory
head2 xhr_ilinsky
head2 xxx
=head1 COPYRIGHT
Copyright (
xplanation)}};Jemplate.JSON={parse:function(decodeValue){throw ("This is a Jemplate.JSON.parse "+stubExplanation)},stringify:function(encodeValue){throw ("This is a Jemplate.JSON.stringify "+stubExpla
ction(){Jemplate.Ajax={get:function(A,B){jQuery.get(A,null,B)},processGet:function(A,B){jQuery.getJSON(A,null,B)},post:function(A,B,C){jQuery.post(A,B,C)}}}())
...
}
sub ajax_xhr {
<<'...';
(func
B.setRequestHeader("Accept","text/json; text/x-json; application/json");return this.request(B,null,C)},processGet:function(A,B){this.get(A,function(C){B(Jemplate.JSON.parse(C))})},post:function(A,C,D)
x.get('url/data.json');
var elem = document.getElementById('some-div');
elem.innerHTML = Jemplate.process('my-template.html', data);
or:
var data = Ajax.get('url/data.json');
var ele
r simply:
Jemplate.process('my-template.html', 'url/data.json', '#some-div');
or, with jQuery.js:
jQuery.getJSON("url/data.json", function(data) {
Jemplate.process('my-template.html
g
the template code. Presto, we have full featured JavaScript
templating language!
Combined with JSON and xmlHttpRequest, Jemplate provides a really simple
and powerful way to do Ajax stuff.
=head1