(function(Page){
	
	// Dependencies

	// Shorthands

	// Model
	Page.Model = Backbone.Model.extend({
		cache: {},
		// urlRoot: '/pages',
		// urlRoot: '/wp/api/get_page/?slug=',
		url: function() {
			return 'wp/api/get_page/?slug=' + this.id;
		},
		parse: function(response) {
			return response.page;
		},
		get: function(id) {
			if(this.cache[id] === undefined) {
				this.id = id;
				this.cache[id] = this.fetch({
					success: function(model, response) {},
					error: function(model, response) {}
				});
				// console.log('not cached', this.cache[id]);
				return this.cache[id];
			} else {
				// console.log('cached', this.cache[id]);
				return this.cache[id];
			}
		},
		clearCache: function() {
			this.cache = {};
		}
	});

	// Collection

	// Views
	Page.Views.Single = Backbone.View.extend({
		tagName: 'section',
		id: 'page',
		initialize: function() {
			this.template = _.template($('#page-template').html());
		},
		render: function() {
			// console.log(this.model);
			// console.log(this.model.toJSON());
			content = this.template(this.model.toJSON());
			$(this.el).html(content);
			return this;
		}
	});

	// Router
		
})(App.module("page"));
