Module: Shift::Generator::JavaScriptTemplates

Defined in:
lib/shift-lang/generator/javascript_templates.rb

Constant Summary collapse

IMPORT_JQNODE_STATEMENT =
"var $ = require('jqNode').$;\n"
IMPORT_UTIL_STATEMENT =
"var util = require('util');\n"
IMPORT_MU_STATEMENT =
"var mu = require('mu2');\nmu.root = __dirname + '/views';\n"
IMPORT_DB_STATEMENT =
"_Schema = require('jugglingdb').Schema;\nvar schema = new _Schema('mongodb', {port : 27017});\n"
UTILITY_FUNCTIONS =
"
function writeTemplate(fileName, templateValues, response) {
	if(!templateValues) {
		$.writeFile('views/' + fileName);
	} else {
		var templateStream = mu.compileAndRender(fileName, templateValues);
		util.pump(templateStream, response);
	}
}"
MODEL_NAME_TEMPLATE =
"var <%= model_name %> = schema.define('<%= model_name %>', {"
URL_HANDLER_DEFINITION =
'$("<%= url %>").<%= method %>(function(request, response, data, urlData) {'
REDIRECT_STATEMENT_TEMPLATE =
"$.redirect(<%= url %>);"
WRITE_DATA_TEMPLATE =
"$.write(<%= write_data %>);"
WRITE_FILE_TEMPLATE =
"writeTemplate(<%= args %>);"
APP_START_STATEMENT =
"$.start({port : 8080});"