/* appjet:version 0.1 */

var title = "lib-templates";
page.setTitle( title );

/* appjet:docs */

// see also: http://templates.appjet.net/

/*
usage:
    import('lib-templates');
*/


/* appjet:library */
// Start of template class //
function Template(template) {
    this._template = template;
    return true;
}

Template.prototype._template;

Template.prototype.getTemplate = function() {
    return this._template;
}

Template.prototype.setTemplate = function(t) {
    this._template = t;
    return this;
}

Template.prototype.getTemplateText = function() {
    var template_item = appjet._native.codeSection(this._template)[0];
    var text = 'Template not found.';
    if (template_item && template_item.code) {
        text = template_item.code;
    }
    return text;
}

Template.prototype.toHTML = function() {
    return supplant(this,this.getTemplateText());
}
// End of template class //


/* appjet:server */

var libCode = appjet._native.codeSection("library")[0].code;
import(appjet.appName);

function get_lib() {
    page.setMode("plain"); 
    response.write(libCode);
    response.stop();
}

function get_() {
    print("This is the main page for ", TT(title), '.', BR(),
        link('/docs','docs'), " ", link('/test','test'), BR(),
        "The code for this library follows.");
    print(DIV({style: "margin-top: 1em;"}, CODE(libCode)));
}

function get_test() {
    var t = new Template('template');
    t.number = Math.random();
    print(t);
}

function get_docs() {
    var libDocs = appjet._native.codeSection("docs")[0].code;
    print("This is the documentation for ", TT(title),'.');
    print(DIV({style: "margin-top: 1em;"}, PRE(libDocs)));
}        

dispatch();

/* appjet:template */
Pick a random number: {number}.









© Copyright 2007-2009 AppJet Inc.