Sha256: 171ce7d8f2aa9f51fd8b7d8e0d271e9100bd63670d1e6bfd6e67096c2273f731

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

module Shift
	module Generator
		module PythonTemplates

			IMPORT_WEBAPP_STATEMENT = "import webapp2"

			IMPORT_PYSTACHE_STATEMENT = "import os\nimport pystache\nmu_root = 'views/'"

			IMPORT_DATABASE_STATEMENT = "from google.appengine.ext import db"

			UTILITY_FUNCTIONS = "
def read_file(file_name):
	f = open(mu_root + file_name)
	template = f.read()
	f.close()
	return template

def read_template(file_name, template_values = None):
	template = read_file(file_name)
	if (template_values == None):
		return template
	else:
		return pystache.render(template, template_values)"

			MODEL_NAME_TEMPLATE = "class <%= model_name %>(db.Model):"

			DB_STRING_PROPERTY = "db.StringProperty()"

			DB_INTEGER_PROPERTY = "db.IntegerProperty()"

			REQUEST_GET_VAR_TEMPLATE = "self.request.get(<%= var_name %>)"

			WRITE_FILE_TEMPLATE = "response_result = read_template(<%= file_name %><% if template_values %>, <%= template_values %><% end %>)"
				
			WRITE_DATA_TEMPLATE = "response_result = <%= write_data %>"

			WRITE_RESPONSE_STATEMENT = "self.response.out.write(response_result)"

			REDIRECT_STATEMENT_TEMPLATE = "self.redirect(<%= url %>)"

			WEBAPP2_APPLICATION_TEMPLATE = "app = webapp2.WSGIApplication([<%= routes %>], debug=True)"
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shift-lang-0.1.4 lib/shift-lang/generator/python_templates.rb
shift-lang-0.1.3 lib/shift-lang/generator/python_templates.rb
shift-lang-0.1.2 lib/shift-lang/generator/python_templates.rb
shift-lang-0.1.1 lib/shift-lang/generator/python_templates.rb